Error deploying serverless API

I am trying to deploy my serverless API in order to create a react app. I followed all of the steps here: https://developers.cloudflare.com/pages/tutorials/build-an-api-with-workers#deploying-a-new-react-application-to-pages and was able to successfully build. But immediately after the “Build Successful” message, I get this error. Any ideas on why this is?

Error: :warning: There was an error fetching your subdomain.
Status Code: 404 Not Found
Msg: {
“result”: null,
“success”: false,
“errors”: [
{
“code”: 10007,
“message”: “workers.api.error.script_not_found”
}
],
“messages”:
}

What does your wrangle.toml file look like?

name = “serverless-api”
type = “javascript”
zone_id = “”
account_id = “”
route = “”
workers_dev = true
compatibility_date = “2021-11-23”

kv_namespaces = [
{ binding = “MY_KV”, id = “c2d64ac1b94d447daf93f0013d3a853b” }
]

[build]
command = “npm install && npm run build”
[build.upload]
format = “service-worker”
~

Not sure if they have been redacted for the post but you need account_id and zone_id filled out.

If they are there, have you gone to the workers section in Cloudflare and created your subdomain?

I have added the account_id and zone_id, as well as creating my subdomain and it successfully published. However, when I run the test command, curl serverless-api.signalnerve.workers.dev/api/posts, it provides me with a large html dump with an exception as follows,

Worker threw exception | serverless-api.signalnerve.workers.dev | Cloudflare

Do you know why this is?

That means the worker code threw an uncaught exception. You can run wrangler dev and it will run your code locally for better debugging.