How to manage JWT token stored in cookie in incognito mode?

1.7k views Asked by At

I recently decided to implement JWT authentication in expressjs and storing it in a cookie. Previously I had only used localstorage for storing JWT in frontend(reactjs). But now I have faced an issue with my new cookie storing approach - cookies are disabled in Incognito mode of browser and my app breaks in it. I am not a complete expert on cookies so maybe I am doing something wrong. Also the API is hosted on a different domain than the frontend(are third party cookies disabled in incognito or all of them)? So my question is how do I make it work, currently when I look in chrome dev tools, cookie is not stored apparently at all in incognito mode. Does anyone know how to overcome this problem?

1

There are 1 answers

2
Anand Kashyap On BEST ANSWER

I have confirmed this. Third party cookies are blocked by default by browser in incognito mode. You need to have the API on the same domain so it could work in incognito too.