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

    Spoleto

    04/04/2023, 2:12 PM
    I guess it would be better to write something inside of the worker... IF ?ajax, disregard my code?
  • s

    Skye

    04/04/2023, 2:12 PM
    Yes, that sounds like a much better solution
  • s

    Spoleto

    04/04/2023, 2:13 PM
    Do you mind taking a look and helping me integrate the IF ?ajax, leave me alone
  • s

    Spoleto

    04/04/2023, 2:13 PM
    nb4 all ajax breaks
  • s

    Spoleto

    04/04/2023, 2:14 PM
    LMK if I can drop this code to you privately
  • z

    zaeem

    04/04/2023, 2:23 PM
    not working either
  • k

    kian

    04/04/2023, 2:24 PM
    Do you have an
    account_id
    key in
    wrangler.toml
    ?
  • s

    Spoleto

    04/04/2023, 2:25 PM
    Just FYI, ChatGPT is a beast at answering Cloudflare Worker Problems @all
  • k

    kian

    04/04/2023, 2:27 PM
    Copy code
    js
    const url = new URL(request.url);
    
    if (url.searchParams.has('ajax')) {
      return fetch(request);
    }
  • s

    Spoleto

    04/04/2023, 2:59 PM
    I cannot get a cookie to display on ?gclid to save my life
  • s

    Spoleto

    04/04/2023, 2:59 PM
    Copy code
    const url = new URL(request.url);
    if (url.search.includes('?gclid') || url.search.includes('?fbclid')) {
          response.headers.set(
            "Set-Cookie",
            "pricing-mode=on;max-age=604800;Path=/"
          )
    }
  • k

    kian

    04/04/2023, 3:05 PM
    ?gclid
    and
    ?fbclid
    are assuming that it's the very first search parameter which isn't always true - use the
    .searchParams.has
    method that I used for
    ajax
    .
  • k

    kian

    04/04/2023, 3:05 PM
    Also, change
    headers.set
    to be
    headers.append
    so it can support multiple `Set-Cookie`headers as necessary.
  • s

    Spoleto

    04/04/2023, 3:09 PM
    Still no luck
    • 1
    • 1
  • s

    Spoleto

    04/04/2023, 3:18 PM
    @kian If you can, please check this out^
  • m

    mojmir

    04/04/2023, 4:45 PM
    hey everyone, this might be naive question - we're using Workers in front of S3 for caching, but we're unsure whether it's better to call
    fetch
    with request headers or without them. Our worry is that CF wouldn't be as efficient as if we called it without headers. (we're concerns are passing
    If-None-Match
    header and range requests). Has anyone asked the same question? thanks!
  • s

    SupulCFG

    04/04/2023, 5:36 PM
    Hello guys. Is there a way to add a CC address for cf-email-workers Message.forward option?
  • d

    dave

    04/04/2023, 6:30 PM
    Can I use vitest from inside a Cloudflare Worker running on the "regular" Worker runtime instead of Miniflare? https://miniflare.dev/testing/vitest
  • s

    Spoleto

    04/04/2023, 9:41 PM
    Something to do with Cache on my url. If I access domain.com/?gclid the cookie is not applied. If I hard refresh, the cookie is applied. Any advice??
  • s

    Spoleto

    04/04/2023, 9:46 PM
    However, "url.pathname.toLowerCase()" does not require hard refresh at all
  • s

    silentdevnull

    04/05/2023, 2:30 AM
    Is it possible to have a worker or page function do oauth2 to a endpoint for a api call. The endpoint will be youtube to read chat on a live staream.
  • j

    James

    04/05/2023, 2:34 AM
    oauth2 is all handled over http so yes, that’s very possible
  • s

    silentdevnull

    04/05/2023, 3:42 AM
    Thank you. I was thinking it would but wanted to be sure. I'm hoping to be able to do it with blazor wasm but I wanted to make sure I have a backup plan. Thanks,
  • v

    vector

    04/05/2023, 3:53 AM
    This is the first time I am using the Worker service and I have some questions.Why is my "Worker" frequently requested by unidentified sources and how can I prevent this? My "trigger" domain is a numeric domain like xxx.123456.xyz.
  • v

    vector

    04/05/2023, 3:54 AM
  • k

    keithj

    04/05/2023, 4:01 AM
    Likely to be malware probing for security holes. It will be obvious if you log the requests.
  • u

    Unsmart | Tech debt

    04/05/2023, 4:06 AM
    Your workers have a cert that get generated and all certs are publicly available for bots to see and thus request your domain
  • u

    Unsmart | Tech debt

    04/05/2023, 4:07 AM
    And you can use firewall rules to try and block them but ultimately it's impossible to block all bots
  • v

    vector

    04/05/2023, 7:03 AM
    I get it,thx
  • i

    icedwave

    04/05/2023, 8:30 AM
    Is it possible to find out, for a fetch() call inside a Worker, whether it was served from cache or actually went out as a request?
1...237723782379...2509Latest