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
#Cookies frontend
13 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
Community-Help:
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
I think I am using a third-party cookie; I'm getting that warning. How can I make my project able to use the cookie?
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
Next.js uses the user's token to authorize
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
Yes, this worked for me using the domain .up.railway.app, but I wanted to try if it was possible to use different domains
I think the same. Thank you very much anyway. I will try with the reverse proxy