https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • a

    alexb

    02/20/2023, 10:01 PM
    I just round
    worker routes
  • a

    alexb

    02/20/2023, 10:01 PM
    so do I add the worker to my site with a route?
  • a

    alexb

    02/20/2023, 10:01 PM
    ah this looks promising, cool
  • c

    Chaika

    02/20/2023, 10:02 PM
    You can use Routes to put your worker in front of an existing origin, yea, i.e if you wanted every path on your apex to go to your worker, use
    mydomain.com/*
    in your route
  • c

    Chaika

    02/20/2023, 10:03 PM
    But yea, you can use workers to pass through the request to your origin, and change the response based on your origin's response
    Copy code
    javascript
    export default {
      async fetch(request, env) {
        var originResponse = await fetch(request);
        if (originResponse.status == 530) {
          return fetch("https://backupserver.mydomain.com/{usetheexistingpath, i'm too lazy to do this right for this example, but you could make a URL object off the request.url and change the hostname}")
        }
        return originResponse;
      }
    }
    Or you can completely avoid requesting your origin by returning a response in your worker, etc. Just keep in mind Workers execute before cache, so they will always execute for every request
  • a

    alexb

    02/20/2023, 10:08 PM
    thanks, thats a big help.
  • g

    goshawk716

    02/20/2023, 11:03 PM
    Hello. I need to make load balancing. How to do it? Please help me step by step
  • d

    dave

    02/20/2023, 11:03 PM
    If I call
    waitUntil
    multiple times, will all of the promises be resolved before the Worker is killed, or only the last promise will be resolved for sure?
  • j

    James

    02/20/2023, 11:05 PM
    all of them, to my knowledge. You can also
    Promise.allSettled
    or similar
  • s

    Skye

    02/20/2023, 11:07 PM
    yeah you can call it as many times as you want
  • d

    dave

    02/20/2023, 11:15 PM
    thanks!
  • l

    Lind

    02/21/2023, 2:05 AM
    Can I send an email using cloudflare email workers or normal worker without using thirdparty email delivery api like sendgrid or mailchannels ?
  • u

    Unsmart | Tech debt

    02/21/2023, 2:05 AM
    No cloudflare only does incoming
  • l

    Lind

    02/21/2023, 2:08 AM
    Will it be possible to send in the future ?
  • l

    Lind

    02/21/2023, 2:08 AM
    This is important to me because I currently rely fully on Cloudflare, the only thing left is to manage emails, I would like to have everything in one place.
  • k

    Kot

    02/21/2023, 2:19 AM
    is everything supposed to be a devDep for workers and pages? or does it not really make a difference
  • u

    Unsmart | Tech debt

    02/21/2023, 3:01 AM
    probably not
  • u

    Unsmart | Tech debt

    02/21/2023, 3:02 AM
    just my personal opinion though 🤷
  • d

    dave

    02/21/2023, 5:42 AM
    MailChannels works without an account. You just need to be a CF worker and you can send mail out.
  • d

    dave

    02/21/2023, 5:43 AM
    I’m currently finishing up my email stack and it was way more work than I expected.
  • x

    Xevion

    02/21/2023, 6:57 AM
    What is the worker type for R2 Buckets? I'm really having a hard time figuring out literally any of the types in Workers.
  • x

    Xevion

    02/21/2023, 6:58 AM
    I'm sure it exists somewhere, but it's quite frustrating as Typescript support feels entirely undefined here. All of it is Javascript pretty much.
  • x

    Xevion

    02/21/2023, 7:00 AM
    K, finally found it. IDE didn't provide autocomplete for
    R2Bucket
    .
  • k

    KAKAROT

    02/21/2023, 7:38 AM
    Can any give brief explanation of this https://developers.cloudflare.com/workers/platform/limits/#cache-api-limits Its vary confusing that non if this is clearly documented 512mb/50/5gib in total for how long and in which conditions
  • k

    kian

    02/21/2023, 8:10 AM
    There is no guarantees or limits on time
  • k

    kian

    02/21/2023, 8:11 AM
    Think of it as LRU - if your assets aren’t being requested frequently then they’ll be evicted to make room
  • x

    Xevion

    02/21/2023, 8:20 AM
    I'm getting
    Response closed due to connection limit
    ? Seems like when I launch R2 PUT requests, doesn't seem to mind a bunch of parallel fetch calls
  • h

    HardAtWork

    02/21/2023, 8:20 AM
    How many are you running per Request?
  • x

    Xevion

    02/21/2023, 8:21 AM
    10 fetch then PUT, parallel
  • h

    HardAtWork

    02/21/2023, 8:21 AM
    Workers have a max of 6 outbound connections, though it should just freeze the overflow...
1...229422952296...2509Latest