Hi guys!
Can somebody publish an example of how to upload an ES module worker by API please? The official documentation is not very clear, at less for me.
I'm expecting Unexpected token 'export' issues 😒 Because I'm not being able to set correctly the type to ES Module.
Already tried setting:
- In the header: "CF-WORKER-MAIN-MODULE-PART": "worker.mjs"
- In the metadata:
"metadata": {
"main_module": "worker.mjs"
}
I'm trying it in this endpoint: https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}
Exact error received:
"errors": [
{
"code": 10021,
"message": "Uncaught SyntaxError: Unexpected token 'export'\n at worker.mjs:1\n"
}
I know that is possible to be done with the Wrangler but I want to do it with the API.
Thanks in advance!
0 Replies