cypress: Cookies not being sent in redirect in 3.5.0
Current behavior:
I’m not sure what the issue is, but our Single Sign On Recipe is failing here: https://dashboard.cypress.io/#/projects/6p53jw/runs/32571/failures

Desired behavior:
The Single Sign On should log in and reroute to dashboard page.
Steps to reproduce: (app code and test code)
- Pull down https://github.com/cypress-io/cypress-example-recipes
- Bump
cypress
dependency to3.5.0
npm i
in root directorycd examples/logging-in__single-sign-on
npm start
- in a new tab
npm run cypress:open
Smallest amount of code to run:
it('can authenticate with cy.request', function () {
cy.getCookie('cypress-session-cookie').should('not.exist')
cy.request({
method: 'POST',
url: 'http://auth.corp.com:7075/login',
qs: {
redirectTo: 'http://localhost:7074/set_token',
},
form: true,
body: {
username: 'jane.lane',
password: 'password123',
},
})
.then((resp) => {
expect(resp.status).to.eq(200)
expect(resp.body).to.include('<h1>Welcome to the Dashboard!</h1>')
})
})
Versions
3.5.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 37 (19 by maintainers)
Released in
3.6.0
.Released in
3.6.1
.We’ll try to get a patch release out soon to fix this.
I can confirm, even with 3.6.0. The tests that pass in 3.4.1 (using cookies), all still fail in 3.6.0…
Thanks @brian-mann. Should this issue be reopened until the issue is resolved?
@pete-om Thanks a ton for sharing these details! I will get to work on reproducing this and tracking down the issue. These details are awesome.
FYI, I moved your comment to an issue so we can track this more clearly, as this thread is getting messy. New issue: #5688 You might want to watch it to receive updates.
Reopening since there are still some bugs with cookies + redirects. There is a PR open that should fix the issues people here are having: #5478
Also experiencing issues on 3.6.1
Keep going back to 3.4.1
Heads up for anyone else encountering this, until a patch comes out I’m working around this issue by manually iterating through the set-cookies array, parsing all the key/values out, and calling cy.setCookie(name, value, etcetc) on each cookie
Still not fixed for me either.
Without a workaround, my authentication script still fails in 3.6.1. Cypress still appears to only process the first cookie in the set-cookie array. Everything works as expected in 3.4.1
The auth flow goes like this:
So what we should be left with after all the above is two cookies: token1 and auth token. What I get as of 3.5.0+ is just token1 (from the original get request) and no auth token.
And we’re not going outside our subdomain at any point so the cookies all have the same domain.
Note: if I cy.visit(‘/account/login’), type the username and password in and submit the form, the redirect sets all the cookies correctly and lets cypress log in, this method has never stopped working. It’s only doing it via cy.request that’s failing.
Hope this helps, let me know if there’s anything else I can do 😃
it reproduces on 3.6 also