-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set-cookie header is forbidden in local Wrangler #59
Comments
Thanks for the detailed report! I'll have a look at this tomorrow. |
Hey! 👋 This is definitely a Miniflare issue. The code being used by Wrangler 2 is in the Assuming Coudflare lets you change all forbidden header names, we could just set |
So I think this is a weird disparity between the local Miniflare environment and the Workers platform. I can't append a
set-cookie
header to a response that already exists when running a Worker locally. However this works fine deployed to Workers.There is no
set-cookie
on the response, and no cookie is set in the browser (when run via Wrangler2).You can work around this in two ways. Either set the header as you create the response
or (if you need to amend an existing request, i.e. in middleware), you have to awkwardly make copies
The problem is that the
set-cookie
header is a "forbidden response header name", which means you can't append it to an existing response. This is (correctly according to thefetch
spec) implemented here by Undici (which it looks like Miniflare switched to recently).Does it make sense for Workers to also implement this limitation for
Headers
? It's obviously very useful for server-side code to be able to easily set cookies, and I assume the security reasons for forbidding it in the browser don't apply. Cloudflare already deviated from the spec for.getAll()
, maybe it would make sense here too? 😈 Ideally Wrangler should match the prod environment imo(apologies if this is the wrong place to open this—the Miniflare repo doesn't look up-to-date with what's actually running within Wrangler2 so didn't seem right)
The text was updated successfully, but these errors were encountered: