-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Cookie with path other than root not sent to handlers #2181
Comments
Hi, @ernestostifano. Thanks for reporting this! I am frankly a bit lost in our existing cookie logic. It's been some years since it was originally written, and I'm trying to dig for the context behind every decision. I suspect that most of the things we have right now can be thrown away in v2.0. Also, @chrisguttandin has referenced an issue in the cookie store package that may be helpful to me in uncovering the context: I've thrown together a new implementation for the cookie store, the one that will respect path and also domain: mswjs/cookies#34. But I need to understand the logic we have in place now before making any changes to MSW. In summary, there are two surfaces dealing with cookies:
|
I've also discovered that JSDOM doesn't write cookies to In the browser, you can write any cookies to In JSDOM, nothing will be written. // jsdom
// Given location is the default location of
// http:https://localhost/
document.cookie = 'a=b; Path=/foo' This makes automated testing on our end a bit problematic. We may consider switching the test suite of the cookie store to run in the actual browser. That library is still designed for Node.js as well to act as a singleton and a replacement layer for cookies in Node.js (where no |
Opened a branch with a WIP |
Prerequisites
Environment check
msw
versionBrowsers
Chromium (Chrome, Brave, etc.)
Reproduction repository
https://codesandbox.io/p/sandbox/cocky-torvalds-nsmhv6
Reproduction steps
Just visit the CodeSandbox and see how
goodCookie
is visible, butbadCookie
is not.Current behavior
Cookies with paths other than
/
are not being sent.If you set two cookies as follows:
When making api calls to correctly matching paths,
goodCookie
is sent properly, butbadCookie
is not.@mswjs/http-middleware
./some/path
(https://nsmhv6.csb.app/some/path
) in the CodeSandbox. Probably MSW is using the browser's URL and not the request URL to match cookies to send?Expected behavior
I expect cookies to behave according to the specified path upon creation.
The text was updated successfully, but these errors were encountered: