简体   繁体   中英

Set-Cookie Response Header not setting cookie? Possible path issue

I have a page:

http://localhost:4201/login

Which, when the user hits login, makes a request to:

http://localhost:4201/api/login/authenticate

Which is then proxied to:

https://myserver.com/xms_webapp_dev10/login/authenticate

Whose response contains the following set-cookie response header:

set-cookie: JSESSIONID=B82FB6A0B9E66E822977F954A5ACB14B; Path=/xms_webapp_dev10; HttpOnly

The problem is that the cookie is not getting set on the client browser. This exact same code works in different environments. The only difference I can see between a working environment and this one is the Path value of the cookie. In a working environment Path=/ but here it is Path=/xms_webapp_dev10

Given this setup, any thoughts on why path might be causing an issue or what the problem might be?

Does the path http://localhost:4201/login need to contain /xms_webapp_dev10?

Or is some other URL wrong? Or something totally different is wrong?

The cookie is set, but only for requests on path /xml_webapp_dev10 , therefore you will never see it sent with a request made to /api/... . When proxying requests, you must change the cookie paths if you want the cookies to be sent by your browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM