session cookie set on example.com is invisible to app.example.com, both on https Cookies
Marketing site and login live on example.com, the actual product is on app.example.com. Both https, same certificate, same everything.
After login the cookie is visibly set - I can see it in the response, I can see it in devtools on example.com. Navigate to app.example.com and the request goes out with no cookie at all and I get redirected back to login, which redirects to app, which redirects to login.
Session attribute table of what I have tried attached. What am I not understanding about cookies?
@thea_mandel · 2mo ago · 3 replies
It is the
__Host-prefix and it is doing exactly what it is designed to do.That prefix forbids a
Domainattribute by specification. Not "ignores it" - the browser drops the entireSet-Cookieif you include one. So a__Host-cookie is permanently host-only and there is no combination of attributes that will make it visible on a subdomain. Auth.js uses prefixed names in production, which is why this only appears when you deploy.To share it, override the cookie config: change the name to a
__Secure-one and set the domain explicitly.Keep
SameSite=Lax. A subdomain is the same site, so Lax is not the thing blocking you here and loosening it buys nothing.Reply
Report
@rueben_alsop · 2mo ago
Change the name, not just the domain. If you leave
__Host-in place and add a Domain, the browser rejects the whole thing and you end up with the identical bug plus the confidence that you fixed it, which is a worse state than where you started.Reply
Report
@p99_hana · 2mo ago
And inspect it under Application in devtools on both origins, not the response header on the one that set it. The response tab shows you what the server tried to do, which is not the same as what the browser stored.
Reply
Report