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

Cookies are not set if authentication service is on a different port than web app #3281

Closed
lgodziejewski opened this issue Feb 1, 2019 · 1 comment
Labels
stage: proposal 💡 No work has been done of this issue topic: cookies 🍪 type: unexpected behavior User expected result, but got another

Comments

@lgodziejewski
Copy link

lgodziejewski commented Feb 1, 2019

Current behavior:

Our application has separate services responsible for authentication and delivering our web app. On local environment that would be localhost:4100 and localhost:3000.

baseUrl is set to localhost:3000

Running this code in tests fails:

cy.visit('/');
cy.request({
  method: 'POST',
  url: 'http://localhost:4100/session',
  headers: {
    'content-type': 'application/vnd.api+json', // required by our backend
  },
  body: {
    // credentials as needed
  },
});

cy.getCookie(<session cookie name>).should('exist'); // this fails :(

It would seem that cypress.request() on purpose isolates cookies between different ports of the same domain?

Desired behavior:

As this works in Chrome or any tested (Firefox, Safari, Edge - to be explicit :-) ) other browser, I think
cookies should be set, as described e.g. in this answer

If a global change would be an issue, maybe localhost could be an exemption?

Steps to reproduce:

  • have separate services with authentication and web-app available on different ports
  • set the web-app as baseUrl
  • make a request to the auth api (as in the code above), response contains set-cookie
  • cy.getCookies() returns empty array

Versions

Cypress v 3.1.4
macOS 10.14.2
Chrome 71.0.3578.98

@jennifer-shehane jennifer-shehane added topic: cookies 🍪 stage: proposal 💡 No work has been done of this issue type: unexpected behavior User expected result, but got another labels Feb 5, 2019
@jennifer-shehane
Copy link
Member

Closing due to inactivity. This will be resolved once this issue is released soon: #944

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: proposal 💡 No work has been done of this issue topic: cookies 🍪 type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

2 participants