limikael
Explore posts from serversCDCloudflare Developers
•Created by limikael on 5/8/2024 in #workers-help
Worker uploaded via API: fetch vs service worker
I have been upoading workers via the api using this API: https://developers.cloudflare.com/api/operations/worker-script-upload-worker-module
There are 2 types of runtime APIs when using workers, I think they are referred to as "fetch" and "service worker". What I mean is that I can write my worker like this:
Or:
I think the first one is preferred (fetch). However, when I upload to the API, only the the other one works (service worker). I'm therefore assuming that the service worker API is what is actually being run, it is a lower level thing. The fetch functionality is added by wrangler when it builds. So when uploading via the API we have to use the service worker API. Which is totally ok, just want to check if this is the case?
2 replies
CDCloudflare Developers
•Created by limikael on 5/7/2024 in #workers-help
Enable workers.dev route for worker deployed via API
I'm using the API here to deploy a worker via the API:
https://developers.cloudflare.com/api/operations/worker-script-upload-worker-module
However, after the worker has been deployed, it will not be accesible at its ...workers.dev url. I can enable it in the dash, but I want to enable it also via the API. I can't find the right API call to do this. With a bit of haxxing, googling, and intercepting traffic from the dash, I have come up the following, which actually works, but I can't find any info about it:
https://api.cloudflare.com/client/v4/accounts/...account_id.../workers/services/...script_name.../environments/production/subdomain
But I can't find any docs about this. Also, there is about a minute delay before the page appears, so I'm thinking this is not how it is supposed to be done. How should it be done?
5 replies
CDCloudflare Developers
•Created by limikael on 5/7/2024 in #workers-help
Deploying Workers via API
Where can I find the documentaion for how to deploy a worker via a REST API (i.e. not using wrangler). I found this thread: https://community.cloudflare.com/t/deploy-a-worker-via-http-api/108439/14 pointing to this url: https://developers.cloudflare.com/workers/tooling/api/scripts/#upload-or-update-a-workers-script but it seems to no longer be working. What is the current url?
3 replies
CDCloudflare Developers
•Created by limikael on 1/25/2024 in #workers-help
API Token to deploy a single worker
Is there any way to create an api token that can deploy a single worker? Ideally, I would like to have a token that has access to a worker, a D1 database and an R2 storage (but only one of each). Is it possible? If not, what is the best way to enable a team to be able to work on and deploy a project that uses a worker, without giving the team access to all my workers?
2 replies