Possible to set cookie in fetch?


I’m trying to send a cookie in a fetch get request from my Cloudflare worker, but I don’t seem to be having any luck with it. Tried below and my cookie doesn’t seem to be getting to where I need it to be.

const COOKIE_NAME = "token"
const cookie = parse(request.headers.get("Cookie") || "");

        let headers = new Headers();
        headers.set("Set-Cookie", cookie[COOKIE_NAME]);
        const res = await fetch(`${AUTH_URL}/verify`, { headers });

I’ve also tried adding credentials: true to the fetch init like so:

const res = await fetch(`${AUTH_URL}/verify`, { headers, credentials: true });

, but that just crashes my worker with the error “The ‘credentials’ field on ‘RequestInitializerDict’ is not implemented.”

Really stuck on this - Hoping someone can throw me a bone :slight_smile:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.