Cookie Issue: Works Locally but Fails on Production (Netlify and Render)

25 Views Asked by At

I have an application with both client-side and server-side components.

On the server side, I'm setting the cookie like this:

res.cookie('isAuthenticated', true, {
   sameSite: 'none',
   secure: true,
   httpOnly: false,
   expires: new Date(Date.now() + 60 * 60 * 1000),
});

I also have an authMiddleware where I retrieve the cookie using react-cookie like this:

const [cookies] = useCookies(["isAuthenticated"]);

I'm getting null for isAuthenticated..

For some reason, everything works fine on localhost, but on production, it's not functioning as expected.

My client-side is hosted on Netlify, and my server-side is on Render.

Does anyone have an idea why this might be happening?

0

There are 0 best solutions below