Cloudflare Developers

CD

Cloudflare Developers

Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news

Join

How can we detect web request vs non-web (backend/curl/etc)?

I'm currently using the origin header as part of our access control strategy but realized this header can be set via non-web clients. Is there a strategy to detect requests coming from the web vs curl-type or backend environments?

Alternative to Fetch API (can't add body to GET)

Is there an alternative to the Fetch API within a Cloudflare worker? Axios does not work (as it relies on Node libs) .. I assume other packages will have a similar problem. Reason is because a vendor API requires a body on a GET request and that produces a "TypeError: Request with a GET or HEAD method cannot have a body". At this point I am considering proxying the request via an AWS Lambda but would love a workaround within a the Cloudflare environment.

How to cache a global data?

For example, I want to fetch bitcoin price rate from some website and save it for 5 minutes in a worker environment for every request, how do I do cache it? I'm new to this

Can we do this with tcp connect?

Currently, I have to have a nodejs server that makes this connection, and I use cloudflare to proxy my websocket to this machine. It'd be ideal if Icould make this connection directly from inside cloudflare workers, but I do see the ability to set the servername and alpn protocols. const targetTCPSocket = tls.connect({ host: 'url', port: 443, rejectUnauthorized: true, // Enable certificate validation...

Why do all workers use for same IP for sending requests?

It seems that all the requests sent by workers show the same IP (2a06:98c0:3600::103), as we can see when we request, e.g., https://icanhazip.com/. This behaviour is somewhat unfortunate in cases where we use several workers for webscraping. In my case, if two workers happen to make the same request to a website I want to scrape data from, one of them is refused. Can this be changed by some operation?...

error rate limiting without set custom role

I’m currently testing a public API that goes through Cloudflare and a proxy. I tried with 200 concurrent connections, and it was successful. However, when I increased it to 500 concurrent connections, it immediately failed. Initially, I didn’t set any custom rules for specific rate limits, but I created a rule to skip the rate limit for my public API, and the result was as mentioned above. Is there a certain threshold from Cloudflare that cannot be managed by the user? And how can I fix this iss...
No description

Worker exit IP

Been wondering , is it possible to explicitly choose the region / IP that a subrequest by a workers will exit through ?

Data Dropped from Queue?

I believe I'm seeing some messages dropped from my queue. Some final data in our db is missing and I traced it back to this. Cloudflare dashboard shows 321 messages successfully delivered for my queue. Logpush logs only show 313 events from that queue All of these messages were sent in the same few seconds/min. What happened to the other 8 messages?

520 error received by Client

I have a REST API build on HonoJS running on Cloudflare Workers. Periodically we'll get Sentry errors from our client reporting a 520. The API itself doesn't log these, nor do we see it in our tail logs. How does one debug these 520 errors?...

Global ContextHolder

I'm using Hono on cloudflare workers and my handle functions look like:
async handle(ctx: Context<Env>) { .. }
async handle(ctx: Context<Env>) { .. }
...

Workers technical documentation

Is there any technical documentation on how the wasm file is built and what exactly has to be exposed for it to be a valid wasm for cloudflare and what the zip should look like that is uploaded + where to upload it? Or do I just have to reverse engineer everything and try to find it out?...

Simple logging in development

In development I want to be able to do some logging, like:
logger.debug('Fetching customer with id=%s', id);
logger.trace('Querying database for customer with id=%s', id);
logger.debug('Fetching customer with id=%s', id);
logger.trace('Querying database for customer with id=%s', id);
...

Intermittent Errors Related to Permissions-Policy Header

I am developing an API using Cloudflare Workers and leveraging a free Cloudflare account. This API stores the accessed IP addresses into KV storage, utilizing the features of Workers and KV. Generally, it functions correctly, but occasionally, during certain periods, I encounter the following errors in the console, and the response is not returned. Could you help me identify the cause and provide any possible fixes? ``` Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'run-ad-auction'. Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'private-state-token-redemption'....

Worker is lowercasing URL using Response.redirect

Using this code: ```js async function redirect(request) { const uri = request.url.replace(/^https://.*?//gi, "/"); console.log(uri);...

Cannot find module '__STATIC_CONTENT_MANIFEST' or its corresponding type declarations

I'm using Hono and I want to serve some static files with my Cloudflare worker. I followed the docs and added a worker-site bucket which is the place where my static files are stored, and my index.ts now looks like this: ``` import { Hono } from 'hono' import { serveStatic } from 'hono/cloudflare-workers' import manifest from '__STATIC_CONTENT_MANIFEST'...

Logging into Worker

I get to logging into the localhost of my worker, but I'm not able to access the same file as in the cloudflare wrangler video around minute 14.21 When I try and open vi src/worker.ts I get the row of ~ as opposed to the editable file the presenter is using. Thanks!...
No description

Intermittent errors with wrangler deploy

I have a monorepo with a number of workers and pages apps and am running into issues with deployments via wrangler deploy... For now, I'm using pnpm run -r deploy to run the deploy tasks in each workspace and am getting workers.api.error.unknown [code: 10013], although it's not always on the same app. When I run the deployments individually from each app, everything works fine. Currently there are only 3 workers and 2 pages apps, but I'm planning on having several more of each (and using GHA)....

Web Scraper Proxy Issue

I am hosting a web scraper API on my worker but can't for the life of me get proxies to work on requests. Is there something I am missing?...

How to deploy next app using cloudflare workers?

I know that cloudflare offers pages for easy deployment of next. I cannot use pages because my repo is not hosted on github/gitlab. I looked at next-on-pages project and I am building my project using next-on-pages as the build command in my script which creates a .vercel directory and I have setup the main file of the worker correctly as well. This is my wrangler.toml file: ``` name = "dashboard"...

Trying to subscribe to paid workers plan but getting error "Internal Server Error (Code: 1000)"

We are unable to subscribe to workers paid plan, we tried with other payment methods (paypal, credit cards) without luck... Please help 🙏🙏🙏...
No description