https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-help
  • having trouble hosting
    b

    br33zyk1lla

    01/07/2024, 8:14 PM
    I registered my domain with cloudflare because the website advertised the ability to host made webpage; i made a website and uploaded it to clloudflare pages as well the site should route through to a custom domain but when clicking to visit site i just get a 404 message
  • Worker to Worker fetch
    m

    mr.goodman

    01/08/2024, 2:12 AM
    Hi there, I would like to ask for some help with my cloudflare worker. When i make a request to another cloudflare worker of mine that holds a variable with data in it from another cloudflare worker. The data returned is empty, however i make the data request from my browser or api tester, it returns the correct data. It is specifcally when I request the data from a cloudflare worker.
    Copy code
    js
    import { Router } from 'itty-router'; const router = Router()
    
    order_data = [];
    
    //admin only
    router.get("/order", async (req) => {
       return new Response(JSON.stringify(order_data));
    });
    m
    e
    +2
    • 5
    • 163
  • How to use the hibernatable websocket API on workers + durable objects?
    c

    ceifa

    01/08/2024, 11:51 AM
    I'm creating a worker + DO that accept websocket requests. I'm a little bit confused of how do I implement the hibernatable API. Does someone have an example? And also, how do I know that I did it right?
    u
    • 2
    • 2
  • Modify request before calling other worker on specific URL
    m

    McSneaky

    01/08/2024, 2:28 PM
    Is it possible to modify request before passing it to binding? Let's say I have code like this on top level worker that sits on https://example.com/edge/backporter
    Copy code
    ts
    import { Router } from 'itty-router';
    const router = Router();
    
    router.get('/edge/backporter', async (request) => {
      request.query = '?foobar' // modify request
      // Set URL to specific URL in other worker
      request.url = '/edge/v1' // Error, cannot set read-only property
      return env.BINDING.fetch(request);
    }
    And on
    BINDING
    worker I have router that responds to certain URL only https://example.com/edge/v1
    Copy code
    ts
    import { Router } from 'itty-router';
    const router = Router();
    
    router.get('/edge/v1', async (request) => { ... }
    I'd like to make sure request from first worker ends up in
    /edge/v1
    , but it never does, since I can't change request URL, nor can I
    request.clone()
    , since then URL would match
    /edge/backporter
    and not
    /edge/v1
    Is anything like this possible?
    k
    • 2
    • 8
  • DB sometimes returns rows, sometimes returns nothing
    m

    mitya2364

    01/08/2024, 6:01 PM
    I wanted to raise this formally although I've been discussing it in #1150557986239021106 , as I'm not sure where in the CF stack the issue lies. Basically a single query in my app, among hundreds, sometimes returns rows and sometimes returns this:
    Copy code
    {
      command: null,
      rowCount: null,
      oid: null,
      rows: Array(0),
      fields: Array(0)
      ...
    }
    All other queries work fine, as I say. So I'm sat here refreshing and endpoint and sometimes seeing data and sometimes not (with no code changes). This is happening while running my app locally (with
    --remote
    ) so HD is being used. So I assume this is a HD issue, though perhaps it's at a Workers/Wrangler level for all I know. I could disable HD caching, but then that presumably defeats the point of HD? Any help is greatly appreciated as this is blocking me at the mo! Thanks in advance.
    e
    • 2
    • 4
  • Workers and WebSocket pricing estimate
    a

    alexander9602

    01/09/2024, 2:52 PM
    Hi !> I have a question regarding workers and their pricing when connected to a websocket. Assuming my use case is a realtime multiplayer game and I want to synchronize the state between players such as player position, rotation etc. The client sends updates to the websocket server 5 times a second and worker writes to Upstash Kafka for global distribution of the message. In this case can somebody help me, will my worker be billed for all those 5 requests a second so billed for : ``5 * 3600 * 24 * 30 = 12,960,000 ``packets per month ?
    • 1
    • 1
  • An itty-router-openapi app stopped working with TypeError: o3.replace is not a function
    t

    Tolmieme

    01/10/2024, 7:03 AM
    After a week of developing a small REST API which was working beautifully, suddenly this error just appeared. Going back to previous verisons of my code doesn't work, neither does reverting to previous wrangler versions, deleting node_modules and reinstalling, restarting machine ... any idea how to proceed?
    r
    • 2
    • 8
  • Tried subscribing for R2 but getting error with card details
    b

    birensz

    01/10/2024, 12:51 PM
    Hi, after trying with multiple Visa, Master and Amex cards to subscribe R2 service but still getting error. "There was an error processing your card. Please check your details and try again."
    z
    h
    • 3
    • 3
  • Storage Technologies
    j

    jshuff

    01/10/2024, 1:04 PM
    We're partly porting over functionality that uses MongoDB for JSON document storage, so I'm looking at the best option for storing this data on Cloudflare (and if not on Cloudflare, what the best storage tool in the ecosystem is). I want to help understand the storage technologies and help understand their pros and cons.
    k
    • 2
    • 1
  • React Native + Worker + KV
    h

    hzia

    01/10/2024, 2:38 PM
    Hello, I'm currently making a React Native app and I'm trying to get/send data to my KVs in cloudflare, however I'm not getting this to work. I'm new to cloudflare and workers in general, help would be appreciated. This is my fetch request currently, I don't know what to put in my worker to communicate with the KVs:
    Copy code
    ts
    fetch('WORKER_URL', {method: 'GET'}).then((response) => response.json()).then((json) => {
        console.log(json);
      }).catch((error) => {
        console.error(error);
      });
    My worker is currently just default with the Response Hello world due to not knowing what to do.
    n
    • 2
    • 4
  • R2 Access Via Domain is Down?
    c

    colearendt

    01/11/2024, 2:36 AM
    Howdy! I got a report from some of my users that R2 is no longer serving content. Everything from my custom domain is returning a 200 with 0 bytes (even if the file does not exist). For example: https://cdn.btst.io/test.html
    Copy code
    curl -i https://cdn.btst.io/test.html
    HTTP/2 200
    date: Thu, 11 Jan 2024 02:34:45 GMT
    content-length: 0
    access-control-allow-origin: *
    vary: Origin
    access-control-allow-credentials: true
    access-control-allow-headers: Content-Type, Vary, Origin, Referer, User-Agent, Authorization
    access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD
    report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=8OA78wCnvcRLW8CC5ljmtce%2BUhoPFbwNekVtEOQFJR2pMlYT5PVokesuCbId8U2u05wrqi3%2FkxP3kUy3K92R%2BvEg3w7XGcMk5vQraiHBgoKxbYMbUfBYchbrM4woyQ%3D%3D"}],"group":"cf-nel","max_age":604800}
    nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
    server: cloudflare
    cf-ray: 8439c3330d605cae-RDU
    alt-svc: h3=":443"; ma=86400
    I don't know how long this has been happening, but I don't see any evidence reported anywhere? Is this an issue on y'all's side?
    k
    c
    • 3
    • 31
  • Can we lookup instances of DOs from one DO's WebSocket message handler?
    u

    98thpixel

    01/11/2024, 4:45 AM
    I’ve been trying to using DOs for websocket handling, I’ve seen that the message handling function is getting called when I send a message from the front end. However, I also saw that there is no context object being passed to that function. How can I lookup other DO instances in the function that handles incoming websocket messages? Thanks in advance
    h
    m
    • 3
    • 3
  • secrets: `.env.SECRET_NAME` or `context.env.SECRET_NAME`
    e

    endymion1818

    01/11/2024, 11:03 AM
    I have a `.dev.vars`locally with some secrets, and Wrangler is telling me they're available, however in my worker I've tried both
    ${env.SECRET_NAME}
    and
    {context.env.SECRET_NAME}
    , neither of which is resolving. Does anyone know what might be the issue? Since the documentation mentions both approaches, I am suspicious that either might be incorrect.
    h
    • 2
    • 2
  • cf-binding-proxy with sveltekit for HMR
    s

    sik.page

    01/11/2024, 12:37 PM
    I'm using cf-binding-proxy, drizzle ORM, and Sveltekit. I'm using "npx cf-binding-proxy --d1=db" and "npm run dev" at the same time. This is to use HMR of sveltekit. The cf-binding-proxy part continues to rebuild every time the file modifies, making it difficult to access from the npm run dev server. Is there a similar problem or any workaround?
    b
    • 2
    • 7
  • RCLONE Upload multi part files failed
    v

    vinomancer

    01/11/2024, 1:37 PM
    Hello Everyone, I have some issues where I can't upload my file with rclone. This is the error message that I got: 2024/01/11 20:33:16 ERROR : Attempt 1/3 failed with 1 errors and: multi-thread copy: failed to write chunk: failed to upload chunk 4 with 5242880 bytes: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your secret access key and signing method. status code: 403, request id: , host id: I need help figuring out how to resolve this issue so I can backup my files. Thanks.
    k
    • 2
    • 4
  • Where are functions located?
    e

    endymion1818

    01/11/2024, 2:22 PM
    Feels a bit silly asking this but I keep calling or visiting my function url on my deployed site (like example.com/functions/my-function), but I get a 404 response from my frontend application. What is the correct path for functions once the site has been deployed? Could anything else be happening here?
    c
    • 2
    • 5
  • Question about Pages, Workers, and Functions
    p

    para.doxical

    01/11/2024, 4:31 PM
    Hello, I'm trying to wrap my head around how these products integrate. I have pages website and I want to be able to pull data from a R2 bucket in order to be displayed on the Pages site. What is the correct way of doing this? Creating a worker that handles the R2 bucket access and then having the pages site access via api? Or creating a function that access the bucket and forgo the worker? When the worker or page has an R2 binding, I assume secrets are not necessary?
    k
    • 2
    • 3
  • Are the examples on docs out of date?
    e

    endymion1818

    01/11/2024, 4:48 PM
    I'm talking about the ones one developers.cloudflare.com/workers/examples. Using
    export default
    causes the error
    Copy code
    Error: No routes found when building Functions directory
    k
    • 2
    • 2
  • POSTing to a function results in no response
    e

    endymion1818

    01/11/2024, 5:08 PM
    I'm using a form action to post to my function
    Copy code
    <form method="POST" action="/functions/send-email"
    However Wrangler keeps erroring with "No response" My function is:
    Copy code
    export async function onRequest() {
      return Response.redirect('/')
    }
    Please tell me what I'm doing wrong
    n
    • 2
    • 4
  • Remove TextEncoder call on write to stream
    r

    rust

    01/11/2024, 11:20 PM
    I'm diving into streaming responses and I see myself writing this:
    Copy code
    ts
    await writer.write(encoder.encode('<h1>Hello world!</h1>'));
    Is this the right way of appending strings or is it possible to remove the
    encoder.encode
    call of the
    TextEndoer
    ?
    n
    • 2
    • 2
  • WebGL in Workers
    v

    vikiival | KodaDot

    01/12/2024, 10:36 AM
    I am trying to make this via cloudflare workers. But sadly WebGL does not work in cloudflare. What is the usecase? I have a worker that tries to go to the page and is making a screenshot on canvas on the webpage. This implementation is working for 90% of cases, however when someone uses WebGL (in p5js), the returned image from worker is a white screen. I already have an implementation: https://github.com/kodadot/workers/tree/main/capture Working minimal PoC (on Vercel): https://github.com/vikiival/vercelgl https://dev.to/rainerselvet/serverless-3d-webgl-rendering-with-threejs-4o11 I was sent here from #1110268932788588624 https://discord.com/channels/595317990191398933/1110268932788588624/1191708168489812038
  • wrangler pages dev ... what is the functions address??
    e

    endymion1818

    01/12/2024, 12:16 PM
    Again a silly question but it's not in the documentation that I could find. When you're running a local dev server with wrangler, it tells me it's recognised the function, and has copied it to some temp folder, but am I able to access it via the web browser locally? I'm trying to debug things and this would significantly close the feedback loop.
    • 1
    • 1
  • Occasional "error on remote worker" errors
    m

    mitya2364

    01/12/2024, 1:42 PM
    Every so often, seemingly appropos of nothing, I get this (attached). This is while developing with the
    --remote
    flag active. If I quit and restart the server, all is fine. Is this is a known issue, and should I be concerned about this ultimately happening when I host my app for production?
  • Exceeded CPU Limits Errors
    a

    ACS

    01/13/2024, 3:20 AM
    Hello, I use Workers with Queue, but I occasionally encounter the "Exceeded CPU Limits" error. Is it possible to change from bundled to standard or unbound ? I try change to unbound in settings page but I got error "Workers Unbound has not yet been enabled for this account. (Code: 10075)".
    n
    e
    • 3
    • 9
  • Extremely Simple "Hello World" Worker takes ~ 190 ms
    r

    rajiv 🍉

    01/13/2024, 12:15 PM
    We are migrating some features of our to use cloudflare workers, so that we are on edge, and can give response times < 100ms The response times are high, and we were not able to optimize. So, I deployed a hello world example here: https://hello-world.betalectic.workers.dev/ The example I deployed to above url is: https://github.com/cloudflare/workers-sdk/blob/main/templates/worker/index.js Is this what to expect from CF Worker? (So, we just find an alternative?)
    a
    • 2
    • 3
  • How to put environment variables in wrangler
    a

    Alka

    01/13/2024, 4:30 PM
    Hi Guys I'm very new in cloudflare ecosystem, i just build sveltekit website and deploy it in cloudflare pages and so far it is working perfectly with supabase as a backend. recently i also have a needs where i need to make a rest api, and i try to use hono js and deploy it in cloudflare workers. the questions is how i can put environment variables in my projects? and how i can access it in my index.ts?
    n
    c
    • 3
    • 3
  • is there a way to check compatibility flags and dates on an older manually created CF Worker?
    u

    .crossbeau

    01/13/2024, 5:57 PM
    Seen title
    c
    • 2
    • 2
  • i wanted to set up this for my friend group https://github.com/mdcfe/spigot-drama-generator
    j

    jax16276

    01/13/2024, 6:49 PM
    Im new to wrangler and i need some help doing this, i have a cloudflare account setup.
    c
    • 2
    • 10
  • "Could not send your email. Please try again." with MailChannels Pages Plugin
    z

    zank.it

    01/13/2024, 10:13 PM
    I m trying to send emails from a form in a astro static site I m making but I couldn't find a way to make it work. I followed the guide https://developers.cloudflare.com/pages/functions/plugins/mailchannels/#spf-support-for-mailchannels Right now I m not using cloudflare email routing as I m using google workspace, but I suppose it should work anyway, correct? - So i created the
    _middleware.ts
    file (code on first comment), having
    "@cloudflare/pages-plugin-mailchannels": "^0.1.2"
    on the dependencies - On the form I added the attribute
    data-static-form-name="contact"
    - Added includes to my existing spf record so now look like this
    v=spf1 include:_spf.mx.cloudflare.net include:relay.mailchannels.net include:_spf.google.com -all
    - Generated DKIM Credentials following the guide https://developers.cloudflare.com/pages/functions/plugins/mailchannels/#generate-dkim-credentials - Added to environment variables (see image) - Added the TXT record mailchannels._domainkey (see image) - Added domain lockdown (TXT
    _mailchannels
    ) with both workers domain and my domain as stated here https://community.cloudflare.com/t/introducing-mailchannels-domain-lockdown/523913/5: `v=mc1 cfid=majestico.workers.dev cfid=majestico.it `(and see image) Now when i try to send email from https://majestico.it/contact/ I get the error "Could not send your email. Please try again." Am I missing something? Is there a way to debug this problem and get a significant error? Thanks
    d
    • 2
    • 3
  • Download BIN files (R2 Binding)
    g

    Gtadictos21

    01/13/2024, 10:22 PM
    Hello! I need to download files that are stored in R2 using CF Workers as a middleman (for auth). Whats the best way to download files from R2 using Workers as the middleman? Files are < 10MiB
1...678910Latest