How can Response not set cookies in responses? #2328
-
From the docs:
I'm confused about how you supposedly can't add cookies to a response. new Response('hello world', {
headers: {
'Set-Cookie': 'x=1'
}
}) Or is this just talking about in the browser? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, @zwhitchcox. That comment references the forbidden cookie names as per the Fetch API spec, which includes the MSW provides a universal |
Beta Was this translation helpful? Give feedback.
Hi, @zwhitchcox. That comment references the forbidden cookie names as per the Fetch API spec, which includes the
Set-Cookie
. That limitation applies everywhere you have a faithful Fetch API implementation. Server-side implementations ignore certain aspects of the spec so you can set the cookie header in Node.js.MSW provides a universal
HttpResponse
class that allows for theSet-Cookie
header anywhere.