Redirect to subdomain has incorrect cookie value.
See original GitHub issueCurrent behavior
When redirecting from web server (dev.mydomain.com) to api server (api-dev.mydomain.com) and setting baseUrl in the run command then the cookies for the redirect have the incorrect subdomain and thus get stripped from the request to the api server.
Desired behavior
Don’t touch my cookies.
Test code to reproduce
baseUrl is set to dev.mydomain.com
cy.getCookie('mycookie').then(c => {
const mycookie = c.value;
cy.log(mycookie);
cy.setCookie('mycookie', mycookie, { domain: '.mydomain.com' }).then(() => {
cy.getCookie('mycookie').then(cookie => {
expect(cookie.domain).to.eq('.mydomain.com');
// at this point the code fails because the domain is 'dev.mydomain.com'
});
});
});
Versions
Worked in 5.x. Doesn’t in 6.x
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Creating a subdomain Auth cookie then redirecting to ...
Store the subdomain in the cookie value itself. Create a secure document container that lists the subdomains to which the user is granted...
Read more >Problems with settings cookies in case of redirect to subdomain.
This is a problem, if in any case, you are using domain example.com as main domain, but do not set up correct redirection...
Read more >Using redirects - AWS Amplify Hosting
Redirects enable a web server to reroute navigation from one URL to another. Common reasons for using redirects include: to customize the appearance...
Read more >RFC 6265: HTTP State Management Mechanism
Although cookies have many historical infelicities that degrade their ... Using the Set-Cookie header field, an HTTP server can pass name/value pairs and ......
Read more >Cookies, document.cookie - The Modern JavaScript Tutorial
By default, a cookie is accessible only at the domain that set it. Please note, by default a cookie is also not shared...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another update is that yesterday we downgraded Cypress to v5.6, and things work as expected, even with baseUrl set. Hope the additional context is helpful . . .
@Qarj I’d add to @jkyoutsey 's last sentence, that “against localhost” means that we are running our front-end app on localhost and Cypress is running its test against that app; and that app is configured to proxy API requests to dev.* or api-dev.* as appropriate. So the server end of this equation seems to be working as it should. It’s only when we point Cypress at the front-end app deployed to dev.* through the baseUrl parameter that things break down.