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

    ginkoid

    01/13/2021, 1:22 AM
    yes use wrangler
  • g

    ginkoid

    01/13/2021, 1:23 AM
    actually im not sure if the code run in quick edit runs on GCP, or its just outbound requests being proxied through GCP
  • g

    ginkoid

    01/13/2021, 1:23 AM
    but regardless, cloudflare ips arent being used for quick edit
  • s

    Spoofh

    01/13/2021, 1:24 AM
    ok, but when i push the code with wrangler the worker is running at cloudflare and uses there ips?
  • i

    itsmatteomanf

    01/13/2021, 1:25 AM
    I believe it should, but one from the team would be able to confirm. @User, maybe.
  • i

    itsmatteomanf

    01/13/2021, 1:25 AM
    You could also deploy it to the .workers.dev subdomain just for testing or a different URL and put Access in front to limit access to the feature.
  • i

    itsmatteomanf

    01/13/2021, 1:26 AM
    Access is free for a single user (and a bit more) or bypass by IP.
  • s

    Spoofh

    01/13/2021, 1:28 AM
    Ok i will try some things
  • i

    itsmatteomanf

    01/13/2021, 1:28 AM
    If you need help we are here (or better, others are for the next few hours, I'll be sleeping...)
  • k

    kenton

    01/13/2021, 1:39 AM
    FWIW,
    wranger dev
    runs on our real edge, not GCP. But the online editor and its preview still run in GCP. Eventually we want to switch those over to the
    wrangler dev
    architecture. So much to do...
  • t

    Torch

    01/13/2021, 5:30 AM
    Hey guys , I am using nextjs to build our product page with authentication , I am having hard time implementing auth using AWS SDK , can't use Amplify because not compatible with cloudflare workers. Are there any FOSS authentication libraries you would suggest using which are compatible with Cloudflare workers ?
  • k

    kristian

    01/13/2021, 5:53 AM
    if you're interested in using auth0, i wrote a tutorial for our docs last year that covers using it in your workers app https://developers.cloudflare.com/workers/tutorials/authorize-users-with-auth0
  • j

    JustinNoel

    01/13/2021, 8:58 AM
    I'm trying to work on some caching of assets fetched from a worker. In my worker, I'm see that the request headers are an empty object
    {}
    . However, I'm absolutely certain my browser is sending headers because I'm using Proxyman to watch the requests/responses. Is this expected behavior? Does Workers strip headers before they are processed?
    Copy code
    addEventListener("fetch", (event) => {
      const { request } = event;
      console.log("addEventListener -> request.method, request.url");
      console.log(request.method, request.url);
      console.log("addEventListener -> request.headers");
      console.log(request.headers);
    
      event.respondWith(handleRequest(event));
    });
    This image shows the logging from the code above:

    https://justinnoel.dev/shared/Cloudflare:Workers-Request-Headers.png▾

    This image shows the logging of the actual event that CF received using
    wrangler tail
    . It clearly shows that there were headers in the original request.

    https://justinnoel.dev/shared/Cloudflare:Workers-Request-Tail-Event.png▾

  • g

    Greg Brimble | Cloudflare Pages

    01/13/2021, 9:04 AM
    If you switch it out for
    console.log(Object.fromEntries(request.headers.entries()));
    , does that work?
  • j

    JustinNoel

    01/13/2021, 9:08 AM
    it does!
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2021, 9:08 AM
    Fab! The Headers object continually catches me out. It never behaves quite like I'd expect, but that's just the spec, not how it's been implemented in Workers. https://developer.mozilla.org/en-US/docs/Web/API/Headers
  • j

    JustinNoel

    01/13/2021, 9:08 AM
    Thanks!
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2021, 9:09 AM
    It's not just a plain object like I always expect it to be, so you need to do stuff like ^ to get all the data out of it.
  • j

    JustinNoel

    01/13/2021, 9:10 AM
    Yep, I've been all over the MDN docs but failed to click the
    .headers
    link here: https://developer.mozilla.org/en-US/docs/Web/API/Request It makes it look like you can simply access them like :
    Request.headers
    . Thanks so much!
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2021, 9:10 AM
    No worries! 🙂
  • a

    anppar

    01/13/2021, 10:30 AM
    Did cloudflare worker support hybrid apps like nextjs
  • p

    Peps

    01/13/2021, 10:47 AM
    no, but also yes at the same time
  • p

    Peps

    01/13/2021, 10:48 AM
    Next.JS is normally meant to be ran in node.js environments, which Workers are not.
  • p

    Peps

    01/13/2021, 10:48 AM
    However, there is https://fab.dev/ which does make it possible to create a bundle with next.js that works on Workers
  • a

    anppar

    01/13/2021, 10:49 AM
    thanks @User
  • m

    macedonian

    01/13/2021, 10:53 AM
    I’m a bit confused about the recommended DNS configuration when you want to link a domain to Cloudflare Workers.
  • m

    macedonian

    01/13/2021, 10:53 AM
    This it what it says in the documentation:
  • m

    macedonian

    01/13/2021, 10:54 AM
    “If your route is configured to a hostname, you will need to add a DNS record to Cloudflare to ensure that the hostname can be resolved externally. If your Worker acts as your origin (the response comes directly from a Worker), you should enter a placeholder (dummy) AAAA record pointing to 100::, which is the reserved IPv6 discard prefixOpen external link.”
  • m

    macedonian

    01/13/2021, 10:54 AM
    Wouldn’t you also need an A record?
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2021, 11:24 AM
    Just a AAAA is enough 😊 (or you can use a similar discard A record instead if you'd prefer)
1...444546...2509Latest