sub domain cookies not working

I set my cross subdomain cookies based on the docs & put credentials: include on requests, but it still doesn't send the cookies to the API
No description
28 Replies
hyteq
hyteqOP5mo ago
set it up like this @bekacru if you don't mind ^^ not many people use this, so it's a bit hard to get help with that
bekacru
bekacru5mo ago
Hey remove default cookie attributes
hyteq
hyteqOP5mo ago
i didn't have those before & it was still not working ^^ does the rest look fine?
bekacru
bekacru5mo ago
yes remove that make sure domain is correct and only enable it on prod
hyteq
hyteqOP5mo ago
will do, gonna check now the crossubdomaincookies: enabled only on prod?
bekacru
bekacru5mo ago
yes
hyteq
hyteqOP5mo ago
done, testing now still no auth cookies being sent to my sub domain sigh
bekacru
bekacru5mo ago
on prod?
hyteq
hyteqOP5mo ago
yeah prod sends a request to my sub-domain with credentials: include, and the auth cookies aren't being sent
hyteq
hyteqOP5mo ago
No description
hyteq
hyteqOP5mo ago
i see these on the prod tho is that why? or is cross site irrelevant
bekacru
bekacru5mo ago
the auth cookies should be sent in general even if the config is wrong the browser is the one which should reject setting those cookies
hyteq
hyteqOP5mo ago
so what should I do? it's refusing to work, not sure how to debug
bekacru
bekacru5mo ago
So when you try to sign-in and it sends 200 check the network tab to see if it showing any warnings first if it can't set the cookie the browser will show some error
hyteq
hyteqOP5mo ago
no it sets the cookie properly & all authentication works fine but sending a request to the API on a sub-domain doesn't forward the authentication cookie though i noticed one weird thing, the cookie domain says ".app.domain.cc" (with the config i sent), is it supposed to be .domain.cc? might just use bearer instead tbh it's being weird even bearer won't set to localStorage sigh not sure how i'll handle auth now
bekacru
bekacru5mo ago
yes. you should put the root domain
hyteq
hyteqOP5mo ago
i did though
bekacru
bekacru5mo ago
hmm, you set to local storage yourself
hyteq
hyteqOP5mo ago
i put .domain.cc on the domain part i did ^ it still puts .app.domain.cc on the cookies
bekacru
bekacru5mo ago
when you send a request to your api, have you added credential include?
hyteq
hyteqOP5mo ago
the cookies are sending now so that's fine, still not authenticating but it's prolly cause of cloudflare getting prisma issues insgeady
bekacru
bekacru5mo ago
what does it mean by "not authenticating"
hyteq
hyteqOP5mo ago
as in 401 authentication required despite the cookie being sent still debugging that but it's probably cause of prisma not working i use prisma to get the user data after getting the session
be_cool
be_cool5mo ago
Hey @hyteq did you get a solution to this ?
hyteq
hyteqOP5mo ago
nope
be_cool
be_cool5mo ago
I having the same issue here.
sebastian
sebastian5mo ago
Have you guys tried going into incognito and then doing the request? Also, if you share auth.ts both in the client and server, both of them should have crossSubDomainCookies in their config. (Only for production as localhost is the same domain)
be_cool
be_cool5mo ago
ahh, I forgot to change the domain in my env variables. It now works

Did you find this page helpful?