Next.js Discord

Discord Forum

Cookies not setting, even after trying to overwrite them

Answered
Crucian carp posted this in #help-forum
Open in Discord
Crucian carpOP
Hey, so i use firebase for authenticating my users in the site. So i am using a user context to replace the cookie field with a custom cookie which token is the user id token from the firebase credentials. But it's not working as intentded.
Answered by Toyger
same thing basically, you just need to set cookies for specific domain with which client open site and it should work.
View full answer

9 Replies

Toyger
more likely you are trying to set secure cookie on http protocol
you need something like that https://github.com/FiloSottile/mkcert for having localhost valid ssl
Toyger
theoretically yes, but there can be some other problem so hard to say with 100% certainty
Crucian carpOP
True, i'll try it thanks for letting me know
Crucian carpOP
@Toyger another question, if i were to use ngrok locally to do this. Would it work?
@Crucian carp <@536484914221285376> another question, if i were to use ngrok locally to do this. Would it work?
Toyger
ngrok works as reverse proxy, so if your domain correctly will be set in code then yeah.
because by default you'll have some https://54h45jhg.ngrock.... domain but your code more likely will try to set cookies for http://localhost:3000
@Toyger ngrok works as reverse proxy, so if your domain correctly will be set in code then yeah. because by default you'll have some https://54h45jhg.ngrock.... domain but your code more likely will try to set cookies for http://localhost:3000
Crucian carpOP
yes it will, so theoretically it won't work on deployment aswell then. I am using nginx to tunnel the traffic to the localhost over my vps
@Crucian carp yes it will, so theoretically it won't work on deployment aswell then. I am using nginx to tunnel the traffic to the localhost over my vps
Toyger
same thing basically, you just need to set cookies for specific domain with which client open site and it should work.
Answer
Crucian carpOP
Hmm