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

    kristian

    01/12/2021, 4:13 PM
    what's everyone working on today?
  • e

    eidam | SuperSaaS

    01/12/2021, 4:21 PM
    Just preparing small project for sharing in #783765338692386886 ! 😈
  • a

    adaptive

    01/12/2021, 4:30 PM
    KV 😜
  • t

    timsuchanek

    01/12/2021, 5:46 PM
    Hey everyone, it seems like the header limit on response headers in CF Workers is 4k per header. Is there any chance this could be increase to something like 16k? I have a use-case where I need to pack up to 16k into the response headers to include metadata. I can split this up right now into multiple headers, but that's a bit hacky
  • t

    timsuchanek

    01/12/2021, 5:47 PM
    Another question: Is there a way to do cache purging based on a key? So basically "tagging" a cache item with a bunch of keys, with which I can then later purge it. Both Akamai and Fastly support that.
  • e

    eidam | SuperSaaS

    01/12/2021, 5:48 PM
    There is a way for Enterprise accounts https://support.cloudflare.com/hc/en-us/articles/200169246-Purging-cached-resources-from-Cloudflare#h_6d756ac9-c476-45e8-a5d4-e2a6e45d9dc7
  • t

    timsuchanek

    01/12/2021, 5:53 PM
    Ok thanks. For now I'm not planning to get an enterprise account 😄
  • d

    Deleted User

    01/12/2021, 6:41 PM
    please stop
  • c

    capslock

    01/12/2021, 7:16 PM
    @User You basically can do that already if you use workers KV.
  • c

    capslock

    01/12/2021, 7:17 PM
    You can get the locale from the headers (or route, however you want) and pass that as a param to get the translated content.
  • c

    capslock

    01/12/2021, 7:24 PM
    If you want to store the strings as keys instead of the locale. Like:
    "Hello": { ..., jp: "こんにちは", fr: "bonjour" }
  • c

    capslock

    01/12/2021, 7:26 PM
    It is still good to use some sort of template language like in the doc above because you can get multiple rewrites or partial rewrites without one.
  • a

    advaith

    01/12/2021, 10:11 PM
    https://cloudflare.com
  • a

    advaith

    01/12/2021, 10:11 PM
    how did you get here without knowing what cloudflare is @User
  • s

    Spoofh

    01/13/2021, 12:09 AM
    I have a question. Is that discord some kind of support or only to promote cloudflare?
  • a

    ai

    01/13/2021, 12:10 AM
    Kinda support but specifically for Workers. Like a real-time version of the community forum.
  • s

    Spoofh

    01/13/2021, 12:47 AM
    So in which channel i can ask if i have a question?
  • a

    albert-zhao

    01/13/2021, 12:48 AM
    hello, welcome :). You can ask a question in any channel, however, this one is the best if you just have a general Workers question
  • s

    Spoofh

    01/13/2021, 12:59 AM
    Ok. Maybe its not the worker only but i want to ask something. I played a bit with some configuration options and now im stuck with a problem. I have an AWS S3 bucket that i want to reach with a worker. In the worker i can get an object from the bucket and get a status 200 response with the image, i made a request for. But when i try to use that worker with a route and a path of my domain and get an access denied repsonse. My worker looks like this.
    Copy code
    javascript
    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request));
    })
    
    async function handleRequest(request) {
      let requestUrl = new URL(request.url).pathname;
      requestUrl = requestUrl.slice(4, requestUrl.length);
      const url = "https://UrlToProvider/bucketName.de"
          + requestUrl;
      return await fetch(url);
    }
    My route is
    Copy code
    https://my-domain.com/img/*
    When i now go to the browser and use the url
    Copy code
    https://my-domain.com/img/path/to/img
    I normally should get that image, but something strange happens. I get an Access Denied reponse and in this response he searched for a key in the bucket. From this example he searches for
    Copy code
    <key>/path/to/img</key>
    But thats the wrong key. The slash at the start is to much. But my url still looks fine. I tried to play a bit with the slice function for the requestUrl, but that only breaks everything. As i mentioned, when i pass a real url to the worker, the worker can get the image and recieve a status 200 from the request.
  • s

    Spoofh

    01/13/2021, 1:03 AM
    My key is as example path/to/img but he searches for /path/to/img. But only outside of the worker with the route. Inside of the worker everything works fine.
  • a

    albert-zhao

    01/13/2021, 1:10 AM
    hmm did you enable public read access for your S3 objects?
  • s

    Spoofh

    01/13/2021, 1:13 AM
    Yes, i can access the bucket over the original url from the provider
  • s

    Spoofh

    01/13/2021, 1:13 AM
    I just dont know why he adds this slash before the key. Im confused.
  • s

    Spoofh

    01/13/2021, 1:16 AM
    ohh ehm. I changed something with the access and now it works. Was still using the IPv4 and IPv6 list of cloudflare in the bucket policy. I removed the condition in the bucket for these ips. But why did that worked in the worker itself before?
  • g

    ginkoid

    01/13/2021, 1:18 AM
    were you using workers preview?
  • i

    itsmatteomanf

    01/13/2021, 1:19 AM
    The question from @User stands, but notice that when going to the origin, maybe S3 is reading the proxied address so it knows it's coming from Cloudflare but from you?
  • s

    Spoofh

    01/13/2021, 1:20 AM
    Yes i use the quickedit on the cloudflare site. Do you mean that?
  • g

    ginkoid

    01/13/2021, 1:21 AM
    quick edit on the cloudflare site is run on GCP
  • g

    ginkoid

    01/13/2021, 1:21 AM
    so the outbound requests will be from GCP ips, not cloudflare ips
  • s

    Spoofh

    01/13/2021, 1:22 AM
    So i should use the wrangler stuff i found in the docs? I mean would you recommend it?
1...434445...2509Latest