Skip to content
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 set with cy.request (set-cookie response) on http local domain is not sent after a 302 redirect on this domain #29371

Open
Lexa-tech opened this issue Apr 22, 2024 · 0 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this

Comments

@Lexa-tech
Copy link

Lexa-tech commented Apr 22, 2024

Current behavior

Hello, I tried to find a related issue before posting but I couldn't find the exact situation.
I use cy.request to send a login request (POST http://local.domain/login) that set a cookie in the response header set-cookie.
If I visit the page http://local.domain/index.html to the same domain, the cookie is sent in the request headers and I am logged to the application.
Then, I use a third party website to log in and get an accesstoken, but when this third part site redirected me to the application with an 302 HTTP redirect (toward http://local.domain/index.html), the cookie is not used.
I see that the cookie is filtered in the debug tools, certainly due to a same-site constraint, but I don't know why this is happening only with the 302 redirect.
If you have any ideas.
This is working with https://local.domain (but we have some constraints to use http).
This is working if I log in using the prompt login/password in ny application (end to end actions), so it seems that cy.request sets a cookie for the browser that cannot be reused with a 302 redirect in HTTP local url
Thanks.

Desired behavior

Cypress should be able to reuse the cookie whith redirect 302, like Cypress does when navigating to the page with a cy.visit.

Test code to reproduce

cy.request http://local.domain/login => cookie is set OK
navigation to the page with cy.visit http://local.domain/index.html => OK, the page is loaded and cookie is sent in request header
SSO login process to a third part app , redirect 302 => error when returning to the page http://local.domain/index.html => cookie is not sent (filtered) and the return to the app is KO
cypress

This is the JSESSSIONID cookie when redirected to index.html

Cypress Version

13.8.0

Node version

18.9.0

Operating System

Windows

Debug Logs

No response

Other

No response

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this
Projects
None yet
Development

No branches or pull requests

2 participants