Next.js Discord

Discord Forum

I have a cookie issue its gets vanished in the production when I refresh

Unanswered
Azawakh posted this in #help-forum
Open in Discord
AzawakhOP
I have a cookie issue its gets vanished in the production when I refresh

29 Replies

Dwarf Crocodile
Does it working fine in the development mode??
Also could you provide the code of setting the cookie?
AzawakhOP
@Dwarf Crocodile Yes its working fine in the dev mode

res.cookie(name, value, {
path: '/',
secure: process.env.ENVIROMENT === 'production',
sameSite: 'lax',
maxAge: 999999999999999,
});

This is my node js code for setting the cookie
@Dwarf Crocodile hey man, can we hop on a meet anytime you free, really need to fix this,
need to go live, would really appreciate your help
Velvet ant
not sure about this one but it seems that the cookie domain is wrong in your video. maybe try to set a domain ? I'm trying to guess so perhaps there is something I'm missing πŸ™‚
AzawakhOP
@Velvet ant The domain you are sayig, showuld it be the domain of the backend or domain of the frontend, coz both are diffirent
Velvet ant
I would say here the domain should be "nexify.club"
and also not sure that process.env.ENVIRONMENT === 'production' is working, secure column is not checked. try process.env.NODE_ENV
AzawakhOP
@Velvet ant res.cookie(name, value, {
secure: process.env.ENVIROMENT === 'production',
sameSite: 'lax',
maxAge: 999999999999999,
domain: '.nexify.club',
});

DOING THIS BUT STILL NOT WORKING
@Velvet ant hey man, can we hop on a meet anytime you free, really need to fix this,
need to go live, would really appreciate your help
Velvet ant
hmm .nexify.club is still wrong for me

res.cookie(name, value, {
        secure: process.env.NODE_ENV === 'production',
        sameSite: 'lax',
        maxAge: 999999999999999,
        domain: 'nexify.club',
      });
AzawakhOP
TRIED THIS TOO STILL NOT WORKING
Velvet ant
cant really jump in a call actually
and do you see the domain correctly set at least ?
AzawakhOP
YES, I HAVE CHECKED.
Velvet ant
dont need to caps lock πŸ™ƒ
AzawakhOP
Can you hop on a call when you are free, like tomorrow.
Velvet ant
will see tomorrow but I think no πŸ™‚
AzawakhOP
You can see here in this ss, a danger sign is shown, and the set-cookie is shown
@Velvet ant will see tomorrow but I think no πŸ™‚
AzawakhOP
No prblm
Velvet ant
did you try with my code example ?
AzawakhOP
Yeah
did it too, still the same issue
the cookie is not even set
Velvet ant
it should be something with railway because it seems that the cookie is set for something.railway.app in your video. is it still the same when you're setting a domain in the Application tab ?
AzawakhOP
Fixed it buddy, thanks for the help
the issue was the frontend and backend should have the same domain
Velvet ant
Good. have a nice day πŸ‘‹