How to enable Route for default workers.dev when deploying Workers Script via API

I am considering deploying Workers Script using the API in the link below. https://developers.cloudflare.com/api/operations/worker-script-upload-worker-module The deployment itself is successful, but when I check Settings>Triggers>Routes of the deployed Script, [subdomain].workers.dev, which is normally set up & enabled automatically, is disabled. https://developers.cloudflare.com/workers/configuration/routing/routes/#routes-with-workersdev I would like to use workers.dev Routes even when deployed by Script via API. I would like to know how to enable “workers.dev" Routes via API or if there is another more appropriate policy.
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Cloudflare Docs
Routes · Cloudflare Workers docs
Routes allow users to map a URL pattern to a Worker. When a request comes in to the Cloudflare network that matches the specified URL pattern, your …
4 Replies
Cyb3r-Jak3
Cyb3r-Jak37mo ago
It is not publicly documented on how to enable it. You would have to reverse engineer the wrangler code to find out.
Mistletoe
MistletoeOP7mo ago
Oh, I see... I'll check GitHub. Does anyone else know about this?
Mistletoe
MistletoeOP7mo ago
I've resolved! I can enable default *.workers.dev route by below API request.
curl --request POST \
--url https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}/subdomain \
--header 'Authorization: Bearer {auth_token}' \
--header 'Content-Type: application/json' \
-d '{"enabled":true}'
curl --request POST \
--url https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}/subdomain \
--header 'Authorization: Bearer {auth_token}' \
--header 'Content-Type: application/json' \
-d '{"enabled":true}'
I found this on wlanger. https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/triggers/deploy.ts#L107
GitHub
workers-sdk/packages/wrangler/src/triggers/deploy.ts at main · clou...
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - cloudflare/workers-sdk
Mistletoe
MistletoeOP7mo ago
this is not documented.
Want results from more Discord servers?
Add your server