#Cookies frontend

13 messages · Page 1 of 1 (latest)

proven pumice
#

Why when I'm in development and when the cookie domain is localhost (payload-token and lng) I can log in to my front end, when I'm in production, when I use the same VPS (in this case Railway) and the cookie domain is .up.railway.app I can also log in to my front end, but when I use Railway for Payload and Vercel for Nextjs and the cookie domain is .up.railway.app it doesn't let me log in

clever ingotBOT
bright ravine
#

Are you trying to let the client make use of the payload cookie from your nextjs app with nextjs and payload being hosted on separate domains? Cause in that case you are using a 3rd party cookie, which likely gets blocked by the browser

proven pumice
bright ravine
#

Do you pull in payload data from the client right now (so in the browser)? Otherwise i think the simplest solution would be to server-side render the data from payload and then spit that out to the client

#

Or does nextjs use the token of the user to authorize itself to payload

proven pumice
#

Next.js uses the user's token to authorize

bright ravine
#

If you can put payload on a custom domain and make your frontend a subdomain of that custom domain then you will be able to make the cookie first party. E.g. you host payload on example.com and nextjs on frontend.example.com, then frontend.example.com will see cookies from example.com as first party too, fixing your problem.

#

If you don't like that solution then the only other way I see is to host both applications through one custom domain is by using a reverse proxy

#

I don't think payload really has anything to do auth without the cookie unfortunately

proven pumice
proven pumice