Uploading worker via v4 API failed to update route

My route (which was using a previous version of my worker) did not update after a new version of the worker was uploaded (with this v4 endpoint).

The route only updated after I clicked “Quick Edit” on the worker, then “Save and Deploy”.

Is there a reason for this? Can I avoid it?

Why would your route update? I use that API endpoint heavily and it just replaces an old script with a new one with the same name. The route doesn’t change, so it just executes the new version of my Worker.
The Endpoint also works to upload a brand new script to a brand new name, but it does not handle routes.

I’m not expecting the route pattern to be changed.

I’m expecting the route to use the new version of my worker.

But it didn’t, until…

after I clicked “Quick Edit” on the worker, then “Save and Deploy”.

I don’t know why the new worker wouldn’t work. As I said, I use this extensively, and the content updates immediately with no need to access the dashboard for a Save & Deploy.

If you feel the Worker isn’t updating properly, I suggest you contact Support and see if they have any suggestions.

To contact Cloudflare Customer Support, login & go to https://dash.cloudflare.com/?account=support and select get more help. If you receive an automatic response that does not help you, please reply and indicate you need more help.

After an upload, you have to deploy the worker :

curl -s -X POST https://api.cloudflare.com/client/v4/accounts/my-account-id/workers/scripts/my-worker-name/subdomain -H "Authorization: Bearer my-token" -H "Content-Type:application/json" --data "{ \"enabled\": true }"

I’m not so sure about that. As I said with an existing Worker using a set Route, any time I PUT new code for an existing Worker, it takes effect immediately.

I can’t find that POST “enable” in the API docs. Can you post a link to it so I can take a look?

1 Like

It is not documented :joy:

But I guarantee you this is the exact POST call made when you click on the deploy button in the Cloudflare Dashboard. You can verify this using Chrome DevTools.

I had the same problem before. Using this POST call led the new version my worker to be accessible. It is 100% mandatory to deploy after upload when you are using the upload API, then want to try your new worker version. You have to deploy it first, either by call or the deploy button in the API.

Note that currently I left the Upload/Deploy APIs and I’m now using Wrangler, because I have also KV bindings and a single Wrangler command makes it simpler to manage all these APIs together.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.