set cookie and redirect: Can't modify immutable headers.
I'm trying to set a session cookie and redirect with a 302 but appending the headers throws this exception:
Can't modify immutable headers.
TypeError: Can't modify immutable headers.
let res = Response.redirect(url.origin+"/my/",302);
res.headers.append("Set-Cookie", "sid=" + user.sid + "; Path=/; Secure; Max-Age=32000000; HttpOnly");
3 Replies
I "resolved" avoiding the problem by using an HTML meta redirect :/
You need to clone the response object before modifying it https://developers.cloudflare.com/workers/examples/alter-headers/
Thank you!