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
23 Replies
hyteq
hyteqOP5d 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
bekacru5d ago
Hey remove default cookie attributes
hyteq
hyteqOP5d ago
i didn't have those before & it was still not working ^^ does the rest look fine?
bekacru
bekacru5d ago
yes remove that make sure domain is correct and only enable it on prod
hyteq
hyteqOP5d ago
will do, gonna check now the crossubdomaincookies: enabled only on prod?
bekacru
bekacru5d ago
yes
hyteq
hyteqOP5d ago
done, testing now still no auth cookies being sent to my sub domain sigh
bekacru
bekacru5d ago
on prod?
hyteq
hyteqOP5d ago
yeah prod sends a request to my sub-domain with credentials: include, and the auth cookies aren't being sent
hyteq
hyteqOP5d ago
No description
hyteq
hyteqOP5d ago
i see these on the prod tho is that why? or is cross site irrelevant
bekacru
bekacru5d 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
hyteqOP5d ago
so what should I do? it's refusing to work, not sure how to debug
bekacru
bekacru5d 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
hyteqOP4d 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
bekacru4d ago
yes. you should put the root domain
hyteq
hyteqOP4d ago
i did though
bekacru
bekacru4d ago
hmm, you set to local storage yourself
hyteq
hyteqOP4d ago
i put .domain.cc on the domain part i did ^ it still puts .app.domain.cc on the cookies
bekacru
bekacru4d ago
when you send a request to your api, have you added credential include?
hyteq
hyteqOP4d 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
bekacru4d ago
what does it mean by "not authenticating"
hyteq
hyteqOP4d 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

Did you find this page helpful?