Hello. There does not seem to have deployment and versioning endpoints for worker for platform like
Hello. There does not seem to have deployment and versioning endpoints for worker for platform like there is for normal workers
is this correct?
ulid from ulidx which was browser safe butDELETE to /accounts/{accountIdentifier}/workers/scripts/{scriptName}/assets/{assetKey} but for user workers?example.my.worker.dev/:user-name/avatar.png?example.my.worker.dev/users/:user-name/index.html? If so, do the API requests count against my account or the user? Apologies if the question seems bizarre, finding it a bit hard to get my head round things without poking code.dispatch_namespace in https://developers.cloudflare.com/workers/wrangler/configuration/
request.cf.zoneName issue? My website is hosted on CF Pages. I am using a CF Worker and want to limit the ability to make an api request to specific zoneName's. The issue I am running into is that request.cf is always NULL. FWIW The code is below, but I have a feeling this might be a DNS or Routing issue. Any and all help would be appreciated.dispatch_namespaces config is not being picked up either?wrangler dev path/to/script) or the main config field.main?dispatch-namespaces-dev branch I'm not sure that supports wrangler.json by default yet..--x-json-config but yeah, toml will work too"18:15:34 [ERROR] Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler. https://developers.cloudflare.com/workers/runtime-apis/handlers/\n at chunks/index_DXfsLD0r.mjs:142:26\n at randomChar (chunks/index_DXfsLD0r.mjs:230:27)\n at encodeRandom (chunks/index_DXfsLD0r.mjs:174:15)\n at ulid (chunks/index_DXfsLD0r.mjs:247:41)\n at chunks/specifications_iCWK4BKj.mjs:1137:29"export default {
fetch(_, env) {
// will return `{ "whatever": "data" }` as a Content-Type: application/json response
return Response.json(env.JSON_DATA)
}
}"bindings": [
{
"name": "JSON_DATA",
"type": "json",
"json": {
"whatever": "data"
}
}
]Support for Workers for Platforms with wrangler dev in local mode is experimental and may change in the future. Use the prerelease branch: wrangler@dispatch-namespaces-dev to try Workers for Platforms locally. // Verify Cloudflare zone
console.log(request.cf);
console.log(allowedDomains);
console.log(request.cf.zoneName);
console.log(allowedDomains.includes(request.cf.zoneName));
if (!request.cf || !allowedDomains.includes(request.cf.zoneName)) {
console.log('[Security] Access denied: Invalid Cloudflare zone');
return new Response(
JSON.stringify({ error: 'Access denied' }),
{ status: 403, headers: { 'Content-Type': 'application/json' } }
);
}