reactjscookiesnext.jsstrapihttponly

HttpOnly cookie not saved in browser


I have a problem with HttpOnly cookie, I have a custom auth API that returns me a HttpOnly cookie with a token when I login, but the problem is, when i make another request in front with Axios using withCredentials, the cookie is not send in the headers and I can't understand why.

I'm using NextJs as a front-end and strapi for the back-end

Here is the request to the API, which returns me the cookie Here is the request to the API, which returns me the cookie

And here is a request that i do just after And here is a request that i do just after

Here is the code that create the second request

await axios.get(param.endpoints.getMe, {withCredentials: true})

Solution

  • Solution

    The problem was that i forgot to add withCredentials: true to the login request.

    I lost 4 hours on this.

    I hate myself