downeydabber
CDCloudflare Developers
•Created by Julio Lobo on 3/6/2025 in #workers-help
How can I increase the number of custom domains supported by workers/pages?
Depends on your usecase / configuration. It is 100 custom domains per zone. You could use different zones for different customers. You can also request an increase to the limit but that is likely only a temporary fix. You could also have the domain point to your worker using DNS records. Or cloudflare for saas as mentioned
3 replies
CDCloudflare Developers
•Created by Mahesh on 3/1/2025 in #workers-help
Workers transiently dropping REQUEST BODY sending empty body to ORIGIN Server.
Assuming this code is correct, on line 18 you have
return await handleFetchWithTimeout(newRequest);
but newRequest
isn't defined. It also looks like you are using ctx.passThroughOnException();
but not catching the request.clone() call in handleFetchWithTimeout
.
My guess is that handleFetchWithTimeout
is being called with undefined, an uncaught exception is occurring when .clone() is run on undefined, and the worker is returning that undefined request with passThroughOnException.9 replies
CDCloudflare Developers
•Created by decryptedchaos on 2/28/2025 in #workers-help
Is it possible to run a REST API with a worker?
Environment variables are attached to the request, so you can't access them outside the scope of the request. Like someone else said, creating the database connection in the global scope is not possible due to this. It is also not great to create a long-lasting database connection on workers which are short-lived processes. It is better to make API calls to the database to provide operations.
You've said you already read the environment variable docs, but read this page: https://developers.cloudflare.com/workers/configuration/environment-variables/
The env object is how you access variables (
env.MONGO_URI
in your case) . But that is an argument passed to the request object, so it has to be used within that context.6 replies
CDCloudflare Developers
•Created by decryptedchaos on 2/28/2025 in #workers-help
Is it possible to run a REST API with a worker?
And even if it was, using a DB connection like this in a stateless / serverless runtime is a terrible idea
6 replies
CDCloudflare Developers
•Created by Mahesh on 3/1/2025 in #workers-help
Workers transiently dropping REQUEST BODY sending empty body to ORIGIN Server.
Well for one, you aren't returning anything. Not really able to troubleshoot / understand whats happening without including the part of the code you are having troubles with. Request/Response bodies can only be read once, so if they are consumed by something and then passed to the user, it is gonna be empty.
9 replies
CDCloudflare Developers
•Created by niconiahi on 2/22/2025 in #workers-help
the "Browser Cache TTL" does nothing
I don't think you can do it directly, but this thread has some workarounds: https://community.cloudflare.com/t/setting-cache-headers-for-static-assets/720802
4 replies
CDCloudflare Developers
•Created by oatmealsunshine on 2/1/2025 in #pages-help
How to deploy to Cloudflare Pages programmatically?
You can use the API endpoints to create a new project but I don't think you can upload the build directory that way. It would probably best to use a ci/cd environment such as GitHub actions and upload the assets using wrangler within the ci/cd. This guide touches on some of the basics: https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/
2 replies
CDCloudflare Developers
•Created by downeydabber on 2/1/2025 in #workers-help
Using local DO bindings from another worker script
Ok I was able to do a little digging and figured out the following:
Once I added a durable_object binding to the DO worker, it is saying that they are connected when I run wrangler dev.
The DO wrangler.json looks like this:
then the output of wrangler dev from the other worker is:
So now it says they are connected, but it is still giving the same error
Error: Cannot access 'DurableObjectClassName#sayHello' as Durable Object RPC is not yet supported between multiple 'wrangler dev' sessions
.
When I use wrangler dev -c wrangler.json -c do-worker/wrangler.json
, they are binding correctly and the output of wrangler dev is
I guess the error makes sense that it can't use RPC between two wrangler dev sessions, but when it is run as a combined wrangler dev section, then the RPC starts to work. Maybe I will just have to use fetch to access the DO during development? It would be really nice to figure out how to use the RPC though, I don't want to have two sets of logic between local and remote.2 replies