ntraithi(Min)
Set-Cookie isn't sent with res header on production
Gonna close this with the solution
1. check cors config
2.check your session, cookie to have these 3 set.
I also set
domain
to client url at first, didn't think it's would cause problem. Unfortunately when I removed it, it worked.
3. trust proxy
app.set('trust proxy', 1);
4. On your client side, when sending request include your credentials
5. If you use see set-cookie in the response header, but no cookies in the next request header. Check your Browser cookie setting and allow 3rd party cookie.18 replies
Set-Cookie isn't sent with res header on production
thank you so much for your advice. I learned from an online course and they dont really teach you how these infrastructure stuff works. Please correct me if Im wrong.
1.When we use CORS, we’re telling server to handle request and response from specific origin only
2. When we deploy to Railway, our server is running behind a proxy server which is like a middleman now.
3. The server doesn’t know that there’s a proxy, and knows only the origin stated in CORS so it refuses to send set cookie to proxy and also to the client.
If we modify the server code to let them know that there’s a proxy (by setting server to trust proxy) , then it should be able to send cookie through proxy and to client.
So does the client has to send their request to proxy address now instead of https://workout-timer-server-production.up.railway.app/ ??
18 replies
Set-Cookie isn't sent with res header on production
Hi Brody thanks for checking in. Could you provide more detail about how this work?
do i just set app.enable('trust proxy',true or client ip.address)? or is there any other thing I should be checking on?
18 replies