This is my first time messing around with session cookies and I'm having a pretty hard time. I'd really appreciate any help!
I'd like to note:
My server is running on http://localhost:7000/
I'm sending cookies to the client from the server by setting the Set-Cookie
header like so:
val cookie = """jwt=$token; Path=/; Domain=localhost; Max-Age=86400; Expires=Thu, 19 Aug 2021 12:20:23 GMT; SameSite=Strict;"""
ctx.header("Set-Cookie", cookie)
I also have cors set up:
it.header(Header.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")
it.header(Header.ACCESS_CONTROL_ALLOW_METHODS, "*")
it.header(Header.ACCESS_CONTROL_ALLOW_HEADERS, "*")
My F.E is running on http://localhost:3000/
Here's what an auth request/response looks like:
Here's what one of the failed requests looks like. Notice how there is no cookie set:
I've also noticed that the cookie does not show up in Chrome's Cookies in use
view:
From what I understand, I can use SameSite=Strict
since both FE & BE are running locally on localhost.
When I move into production, FE & BE will not be on the same domain. Then, I'd have to use SameSite=None; Strict
. Is this correct?
Also, I'm aware that I can also include HttpOnly
, but I'm not at the moment for debugging purposes.
Is my understanding correct?
Thanks in advance for any help you might be able to provide, it's greatly appreciated!
I wasn't properly setting credentials: include
🤦