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
Ddeasydoesit5/9/2024

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...
Hhungnguyenthanh5/9/2024

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) {...
Ffrolic5/8/2024

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/
GGabrielB5/8/2024

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.
MMitya5/8/2024

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?...
Ppeepo5/8/2024

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?...
BblindChicken5/8/2024

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\"."
...
Cconor5/8/2024

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?
Ppreetramsha5/8/2024

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....
BBallisticSwami5/8/2024

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. ...
Llimikael5/8/2024

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...
Wwlodar5/7/2024

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
𝙙𝙧 𝙖𝙑𝙗 ち5/7/2024

React +Vite+ Js in Workers

Hello, I was trying to use the react repo template on github to build a Worker with that model, but it didn't work and I tried using wranlger init and created one inside that folder of npx create-vite, but then it wouldn't be what I wanted. Is there any way or tip for this issue? And how to make C3 from react go to workers without problems? because when I use wranlger init the Website or web app does not create a wranlger.toml
Aanirudhhhh5/7/2024

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
FFuming5/7/2024

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....
Iim.life5/7/2024

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: ```...
HH15/7/2024

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?...
Kkalaivanan5/7/2024

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,...
Llimikael5/7/2024

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...
Llimikael5/7/2024

Deploying Workers via API

Where can I find the documentaion for how to deploy a worker via a REST API (i.e. not using wrangler). I found this thread: https://community.cloudflare.com/t/deploy-a-worker-via-http-api/108439/14 pointing to this url: https://developers.cloudflare.com/workers/tooling/api/scripts/#upload-or-update-a-workers-script but it seems to no longer be working. What is the current url?