I have an SSR nuxt app and laravel backend. In auth, we are using HttpOnly and we are Ok in most of the code but there is a problem in sending requests with fetch and asyncData on the server-side.
I know that only the browser automatically merge a header for auth with request and send it. Now I'm using fetch and this will send requests to the server and there is no browser on the server.
I searched for making custom fetch in nuxt, but I don't find any.
How should I send a request with fetch and asyncdata and do not get a 401 error
?
UPDATE
***: I have to change nuxt
mode to spa
from ssr
unfortunately, because I don't find any answer yet.
fetch won’t send cookies, unless you set the credentials init option. Try setting the
credentials
option tosame-site
orinclude
like this: