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 tooHello, ${name}! });npx wrangler@dispatch-namespaces-dev dev --x-json-config correct?"vars" modify env but "dispatch_namespaces" doesn't?"dispatch_namespaces" doesn't work in local dev mode right now, because I tried deploying and env does have a DISPATCHER key in prod. Is that a bug? The output from wrangler dev implies that it is working:request.cf.zoneNamerequest.cf // 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' } }
);
}dispatch_namespaceswrangler dev path/to/scriptmainmaindispatch-namespaces-dev--x-json-config "devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.6.4",
"vitest": "~2.1.9",
"wrangler": "dispatch-namespaces-dev"
}[wrangler] Couldn't find `wrangler dev` session for "customer-worker-1" in namespace "my-namespace" to proxy to%(method) DispatchNamespace.get(name: string, args?: {
[key: string]: any;
}, options?: DynamicDispatchOptions): Fetcher
@param name — Name of the Worker script.
@param args — Arguments to Worker script.
@param options — Options for Dynamic Dispatch invocation.
@returns — A Fetcher object that allows you to send requests to the Worker script.
@throws — If the Worker script does not exist in this dispatch namespace, an error will be thrown. .get("/", async (c) => {
const customerScript = c.env.DISPATCHER.get("user-worker-dev", {
hook: "afterCreate",
table: "order",
});
return await customerScript.fetch(c.req.raw);Hello, ${name}!npx wrangler@dispatch-namespaces-dev dev --x-json-config"vars": {
"MY_VARIABLE": "production_value",
},
"dispatch_namespaces": [
{
"binding": "DISPATCHER",
"namespace": "<NAMESPACE_NAME>",
},
],export default {
async fetch(req, env) {
console.log('env:', Object.keys(env));env: [ 'MY_VARIABLE' ]"vars""dispatch_namespaces""dispatch_namespaces"wrangler devYour worker has access to the following bindings:
- Vars:
- MY_VARIABLE: "production_value"
- Dispatch Namespaces:
- DISPATCHER: <NAMESPACE_NAME> [connected to remote resource]
⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:8787