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

    chientrm

    04/19/2023, 5:35 AM
    wrangler dev
    not usable every day at lunch time. Keep hanging connection 😐
  • a

    Alisson Acioli

    04/19/2023, 12:32 PM
    Hello, a question about redirection in workers. I'm trying to do a redirect like this: return new Response.redirect('https://www.mywebsite.com', 307); but it is not redirecting. Is there a different way or is my code wrong to redirect from the worker?
  • b

    boywithkeyboard

    04/19/2023, 12:35 PM
    Copy code
    ts
    return new Response(null, {
      status: 307, // temporary redirect
      headers: {
        location: 'https://...'
      }
    })
  • b

    boywithkeyboard

    04/19/2023, 12:35 PM
    @Alisson Acioli that's not worker-specific, rather web standard
  • k

    kian

    04/19/2023, 12:35 PM
    remove the
    new
    before
    Response.redirect
  • k

    kian

    04/19/2023, 12:35 PM
    it's a static method, not a constructor
  • k

    kian

    04/19/2023, 12:36 PM
  • a

    Alisson Acioli

    04/19/2023, 1:40 PM
    worked
  • a

    Alisson Acioli

    04/19/2023, 1:40 PM
    tanks
  • s

    Stu

    04/19/2023, 2:47 PM
    Hi all, is anybody able to help me with this? I just trying to reverse proxy POST requests but not getting very far.
  • k

    kian

    04/19/2023, 2:49 PM
    What is your existing code?
  • s

    Stu

    04/19/2023, 3:12 PM
    https://gist.github.com/smarsh84/0a6250cef5a8853ad64b8dfe80dd5269
  • k

    kian

    04/19/2023, 3:48 PM
    You're sending a JSON body from FormData, but is your origin expecting JSON?
  • s

    Stu

    04/19/2023, 5:00 PM
    I read somewhere that you could JSON stringify the body and as long the content type was application/x-www-form-urlencoded the receiving server would understand it.
  • s

    Skye

    04/19/2023, 5:00 PM
    That's probably pretty dependent on the parser on the server's side
  • s

    Skye

    04/19/2023, 5:01 PM
    You should probably just use
    new URLSearchParams( ... ).toString()
  • k

    kian

    04/19/2023, 5:03 PM
    It doesn't look like the body is being used other than to send it on with
    fetch
    so the entire thing could be simplified down to
    Copy code
    js
    export default {
      fetch(req) {
        return fetch("http://localhost:9000/", req);
      }
    }
  • k

    kian

    04/19/2023, 5:04 PM
    You can adapt it as necessary if you want to implement decisions on where to send traffic based on the path, but there's no need to touch the body or headers.
  • k

    kian

    04/19/2023, 5:04 PM
    Just pass the original
    req
    object as the second argument to
    fetch
  • s

    Stu

    04/19/2023, 5:09 PM
    When I've tried that in the past I get a message that the Response body object should not be disturbed or locked
  • s

    Stu

    04/19/2023, 5:18 PM
    Just tried your code and get the error.
  • s

    Stu

    04/19/2023, 5:21 PM
    I've also tried formatting the body as URLSearchParams.toString() but that's not working either.
  • k

    kian

    04/19/2023, 5:22 PM
    That isn't touching the response body at all - what's the full error output?
  • d

    dave

    04/19/2023, 5:27 PM
    @Erisa | Support Engineer if I get a Ray ID from an error happening in my account, is that enough to get a trace?
  • w

    Walshy | Pages

    04/19/2023, 6:12 PM
    Erisa is OOO but not really
  • d

    dave

    04/19/2023, 6:20 PM
    yeah I didn't buy it tbh ;P
  • s

    Stu

    04/19/2023, 9:02 PM
    Your right, something wasn't making sense. I've removed some redundant code that didn't appear to be doing anything but it's fixed the issue! Thanks for your help, I really appreciate it!
  • c

    coolvibesreloaded

    04/19/2023, 9:26 PM
    can someone please help me im really sorry bout this i'v got now i connected digitaloceans name servers to CF and CF NS to DO could someone help please
  • w

    Walshy | Pages

    04/19/2023, 9:28 PM
    #909458221419356210
  • a

    Akarys

    04/20/2023, 10:49 AM
    I'm looking to have a worker auditable by everyone on the team as it'll be used for keygen ceremonies
1...240424052406...2509Latest