-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Redirects do not honor set-cookie
header
#20476
Comments
Almost wondering if there is a slight delay in the automation API setting cookies on |
Hey @kentcdodds, this looks similar to: #19800, which has a temporary workaround available (changing the |
I had a similar issue with // HACK: cypress seems to drop cookies that have 'Secure;' and 'SameSite=None';
// when used w/ localhost and redirects. As a workaround we intercept the redirect
// response and remove the `Secure` and `SameSite` flags from the cookie values.
// https://github.com/cypress-io/cypress/issues/20476
cy.intercept('/your-endpoint-that-redirects', (req) => {
req.continue((res) => {
const value = res.headers['set-cookie'];
const setCookie = Array.isArray(value) ? value : [value];
res.headers['set-cookie'] = setCookie.map((value) =>
value.replace(/ ?Secure;?/, '').replace(/ ?SameSite=None;?/, '')
);
});
});
cy.visit('/your-endpoint-that-redirects'); |
Haven't tried a workaround yet, but would be nice to have this fixed/implemented in Cypress. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
Current behavior
I have a
cy.request
that ends up doing several redirects (as intended). In one of them a cookie is set along with the redirect location. The next request to follow the redirect does not include the cookie header:Here's my
cy.request
call that starts this chain of redirects:Desired behavior
Cypress should behave as a browser does when following redirects for a
cy.request
call.Test code to reproduce
My repository is open source, you can follow the instructions here to get it set up: https://github.com/kentcdodds/kentcdodds.com/blob/main/CONTRIBUTING.md#project-setup
This is the test I ran to get the screenshot above: https://github.com/kentcdodds/kentcdodds.com/blob/main/cypress/e2e/contact.cy.ts
Cypress Version
9.5.1 (latest at the time of this report)
Other
I've experienced this in another (non-public) project and had to workaround it using
cy.setCookie
manually. I'd love to not have to do that here.The text was updated successfully, but these errors were encountered: