Workers for platforms authentication
How are users authenticated when using Workers for Platforms? Does each user need their own CloudFlare account or is is possible to support deployment on their behalf?
11 Replies
WfP Workers are deployed on your account. They do not require an account for each customer
I see, so how would a user deploy a worker in that case?
Does the user run Wrangler, or would we run wrangler on their code on their behalf? Wrangler requires a login so the user would need an account if they are running it. Also I wasn't able to find a programmatic interface to wrangler (outside of the CLI), so it's hard to e.g. create a cf worker that will provide a deployment interface, since it's hard to run wrangler inside a worker (not to mention you'd need a virtual FS to do this).
Any advice as to best practices? thanks!
Your application would take the user Worker, then upload to WfP via the API
thanks, unfortunately the API crashes for me (opaque internal error on the CF side). I have a ticket open for about 2 weeks now. I was looking for a way to fast track it without having to deal with cloudflare crashing on the backend.
What’s the ticket ID?
Looking
module worker.js.map has unsupported Content-Type application/jsonNot sure why this is returning internal error - i'll look into that but yeah, you're uploading a source map and that isn't supported
ok that's useful info, thanks
so removing the source map worked, but now I'm getting a synax error on
export
I'm building the code with
wrangler build
and then uploading the resulting JS file (which is ESM) with the mapping set for ESM per https://developers.cloudflare.com/api/operations/worker-script-put-contentCloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
I tried using both/either
CF-WORKER-MAIN-MODULE-PART
and the metadata
JSON field main_module
in the FormData
presumably this should allow the worker to be detected as ESM and therefore export
shouldn't be a syntax error but the backend tells me it is
(also note that the documentation says that source maps are supported, Source maps may also be included using the application/source-map content type.
, which is why I was confused why that causes the crash.
I uploaded the built worker file to the ticket as wellyou're trying to upload as a service worker not esmodule worker -- content type for it should be application/javascript+module
and you'll want to use
main_module
in metadata yeah
(sorry i wish this api was easier but we need to support so much stuff it gets complex)
(fwiw if you can use wrangler wrangler deploy --dispatch-namespace <your-namespace>
works)