We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello!
I've been trying many different ways to set multiple cookies on my responses with no luck.
Some of the tested approaches work on the browser (usingmsw directly), but none work while using the http-middleware.
msw
http-middleware
For example, the following works perfectly using msw on the browser, but not using the http-middleware:
return HttpResponse.json( body, { headers: [ [ 'Set-Cookie', `${COOKIE_NAMES.ACCESS_TOKEN}=${session.accessToken.value}; Path=/; Max-Age=${TOKENS.ACCESS_TOKEN_MAX_AGE};` ], [ 'Set-Cookie', `${COOKIE_NAMES.REFRESH_TOKEN}=${session.refreshToken.value}; Path=/; Max-Age=${TOKENS.REFRESH_TOKEN_EXP_MAX_AGE};` ] ] } );
Using the http-middleware, only the last cookie is sent from express.
Other approaches I tried involved using:
Headers
append
headers-polyfill
HttpResponse.json
Response.json
I have the following configuration before the htttp-middleware:
htttp-middleware
app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', req.get('origin') || '*'); res.header('Access-Control-Allow-Credentials', 'true'); res.header('Access-Control-Allow-Methods', '*'); res.header( 'Access-Control-Allow-Headers', 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers' ); if (req.method === 'OPTIONS') { return res.sendStatus(200); } return next(); }); app.use(express.json());
Potentially related issues:
The text was updated successfully, but these errors were encountered:
Hi, @ernestostifano! Thanks for letting me know. The fix is merged, the release will happen later tonight.
Sorry, something went wrong.
This has been released in v0.10.1!
Make sure to always update to the latest version (npm i @mswjs/http-middleware@latest) to get the newest features and bug fixes.
npm i @mswjs/http-middleware@latest
Predictable release automation by @ossjs/release.
Successfully merging a pull request may close this issue.
Hello!
I've been trying many different ways to set multiple cookies on my responses with no luck.
Some of the tested approaches work on the browser (using
msw
directly), but none work while using thehttp-middleware
.For example, the following works perfectly using
msw
on the browser, but not using thehttp-middleware
:Using the
http-middleware
, only the last cookie is sent from express.Other approaches I tried involved using:
Headers
constructor (usingappend
).headers-polyfill
.HttpResponse.json
.Response.json
.I have the following configuration before the
htttp-middleware
:Potentially related issues:
The text was updated successfully, but these errors were encountered: