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 to rapidly validate if a JS package will work on Workers runtime?

Like the old 'Works on Workers' catalogue which disappeared. Node.js / javascript / typescript packages. I know this page exists: https://developers.cloudflare.com/workers/runtime-apis/nodejs/ but without a deep dive into other packages you cannot identify whether a package will 'just work'. As an example of two popular packages, stripe works but @sendgrid/mail doesn't Is it a matter of trial and error? Or Google [package] cloudflare workers each time and hope someone has written a blog post? That will become exhausting quickly....

Newbie Assistance with Worker Code

Hello - I'm fairly new to Cloudflare and I'm making my first attempt at using a Worker. The goal is to have the Worker add a SAS token, from an Azure storage account, anytime a specific URL is processed in CF. For example, if the URL is sub.mydomain.com, add the SAS TOKEN (stored as a variable) so that the URL becomes sub.mydomain.com?<SASTOKEN>. I found a blog post where someone explained how to do this: https://www.eliostruyf.com/cloudflare-serve-private-azure-storage-blobs/ Using the code provided:...

Wrangler versions deploy - deploy latest version?

I'm using wrangler 3.55.0 in the context of a CI/CD pipeline in Github Actions. When a new git tag gets created, I'm trying to perform the following: (1) Create new Worker version via wrangler versions upload for the git tag...

Wrangler dev runtime error on macos

I use macos, I setup a project in local but I cant run wrangler dev src/index.ts MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above. at Miniflare2.#assembleAndUpdateConfig (/Users/0x/Projects/project-alpha/node_modules/miniflare/dist/src/index.js:8989:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Mutex.runWith (/Users/0x/Projects/project-alpha/node_modules/miniflare/dist/src/index.js:3500:16) {...

service binding for ethereum gateway

I am paying for a cloudflare ethereum gateway and I am wondering if it's possible to bind a worker to it via regular binding or service binding to take advantage of the things listed here: https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/

Dynamic CSP Content Security Policy with workers

Hi, I'm injecting the CSP using a Cloudflare worker, the CSP allows loading images from google.com. The issue is when I open the page in Ecuador the CSP blocks an image because the image URL is google.com.ec/ref/... (it is loading from the google's ecuadorian subdomain). This is because Google Analitycs uses the regional domain to load the tracking pixel. How can I update the worker to get the google domain's country of the request e.g. (if Ecuador => google.com.ec) So I can add it to the CSP.

Looking for a really simple explanation of durable objects vs. workers

One problem I repeatedly find with CF docs is that they're not very friendly and seem to assume a lot of knowledge already. I would love to see each product overview have an intro video or something that really explains what the thing is. The docs seem to jump straight into highly technical concepts. With this in mind, what is the relationship between durable objects and workers? Right now I have a worker which powers a chatbot. Users talk to our system via a web interface and our system (i.e. the worker) responds. I'm keen to learn more of the CF ecosystem and would like to see which parts of it might fit into our stack and improve it. Are durable objects their own thing, or are they used in conjunction with workers?...

MailChannels Pages Plugin Issue with Next.JS 14

I've got a CloudFlare Pages project up, and I've set up all of my DNS records in Cloudflare for the Domain Lockdown, SPF, and DKIM according to the documentation: https://developers.cloudflare.com/pages/functions/plugins/mailchannels/ I've got my /functions/_middleware.ts file copied and pasted from the documentation's personalization example and hardcoded the emails, and I've added the data-static-form-name attribute to my form. When I submit the form and check the logs, I only see get requests with 200 response codes, but I don't see any post request and I don't receive an email. Has anyone else run into this?...

Service Binding Error "This Worker no longer exists"

My service binding, in settings, is showing this error message: This Worker no longer exists and can not be used. Please try using a different Worker. But the worker does exist and if I make a browser request to the worker it returns the expected response, and everything looks fine in its logs. I'm trying to bind to the worker from pages. When I make a request through the calling website the pages log shows this:
js"worker error:",
"TypeError: The RPC receiver does not implement the method \"emailFunc\"."
js"worker error:",
"TypeError: The RPC receiver does not implement the method \"emailFunc\"."
...

Worker getting rate limited

I believe my worker is getting rate limited; my frontend client opens up a websocket connection with my worker and sends 2366 messages but my worker only receives 998. Is there some way to increase the limit?

How do I connect mongodb database with mongoose from my hono app and deploy in cloudflare workers?

I want to make an API that scales infinitely and handles as many requests. I am thinking of using cloudflare workers with hono. but I am having a hard time connecting my mongodb database. Please help me connect my database as cloudflare workers is serverless and I am concerned about how many new connections will be made everytime the workers runs or new worker is created. Please HELP....

Unable to connect to MySQL database on AWS RDS

I am unable to connect to my database. Tried the following methods: 1. Used mysql2 package Got error saying connection.connect() does not exist. I think workers doesn't support this package. ...

Worker uploaded via API: fetch vs service worker

I have been upoading workers via the api using this API: https://developers.cloudflare.com/api/operations/worker-script-upload-worker-module There are 2 types of runtime APIs when using workers, I think they are referred to as "fetch" and "service worker". What I mean is that I can write my worker like this: ```js...

Image Resize Disable Cache

I'm optimizing images with cloudflare workers and image resize. I faced a problem, where I upload the same image url twice in short time and the optimized images are the previous ones. As I store the images on cloudlare R2, i dont need to have this images cached to avoid this problem with old images being returned. Is there a way to get around this cache and use this solely for resizing

domain forwarding is not working.

I've added my primary domain under page rules but when I look up my cloudflare domain, it doesn't forward to the primary domain

How do I return a HTML? Hono ts

Hi! I've been trying to return a HTML file on my worker. That HTML is saved in on another file. I need to read it in some way so I can return it using c.html() (Hono way of returning HTML). I've tried reading the file using node, however I get this error message: Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details....

Help with Cloudflare Web Crypto for verifying webhook signature.

I want to verify the webhook sender. Since I am using Worker, then I have to use web crypto for the hash matching. This is my code: ```...

Different Hyperdrive Config for Staging & Production

Couldn't really find resources on it, how to have different Hyperdrive IDs for staging / production? [[hyperdrive.staging]] & then deploy via --env staging?...

How to access to binding variables during nextjs build process?

I'm trying to user D1 with drizzle orm in next js, currently using next auth 5, and using drizzle adapter for that.. How to get the DB instance during build? export const { handlers: { GET, POST }, auth, signIn,...

Enable workers.dev route for worker deployed via API

I'm using the API here to deploy a worker via the API: https://developers.cloudflare.com/api/operations/worker-script-upload-worker-module However, after the worker has been deployed, it will not be accesible at its ...workers.dev url. I can enable it in the dash, but I want to enable it also via the API. I can't find the right API call to do this. With a bit of haxxing, googling, and intercepting traffic from the dash, I have come up the following, which actually works, but I can't find any info about it: https://api.cloudflare.com/client/v4/accounts/...account_id.../workers/services/...script_name.../environments/production/subdomain...