Next.js v12.0.7
NodeJS v14.17.4
I’m trying to create change my authentication from localstorage to a httponly cookie. I’ve chosen to use js-cookie for this but for some reason I just can’t create a cookie with the httponly parameter. I’m using this code below to set the cookie:
Cookies.set('authtoken', 'test', {
path: '/',
expires: 7,
sameSite: 'strict',
httpOnly: true
});
If I remove the httponly then the cookie would be set.. If I keep the httponly I get an error saying:
Cookie “authtoken” has been rejected because there is already an HTTP-Only cookie but script tried to store a new one.
I use Mozilla Firefox as my browser and I’ve tried changing the browser to see if something is up with the browser. Chrome does not state any errors in console but cookie also would not be set with httponly but without, no problemos.
Just in case it could be the value, my value consists of an base64 encoded jwt token. Could this break it?
Do we have any cookie experts out there who could assist, preferably not Santa. I’ve also done a short GIF to show my issue:
https://gyazo.com/16e02f4c095ee3309e1b57d9cabc6bd7
I’m going to keep trying. Was just hoping someone could end my suffering 😉