#How to send the cookie in frontend to a separate backend server?

5 messages · Page 1 of 1 (latest)

dense flare
#

Hi, I am using Nuxt 3 and I want to pass a httponly cookie to the client for authentication. When I do this, I cannot read the cookie with javascript from the client side and pass it to the axios request. Normally, a cookie should be sent automatically to the server but since the cookie has to be given by Nuxt's backend Nitro, it does not pass it to my backend. How can I solve this?

#

By the way the setCookie header does not set the cookie that's why I had to put nitro in the middle.

dense flare
#

anyone?

frail mulch
#

I'm using the included useFetch composable, I just need to pass the option credentials = 'include' and the cookie is sent just as expected, axios probably has something like that

deft flame
#

When I had to do something similar, I called $fetch and set as one of its options headers: useRequestHeaders('cookie') to pass the Cookie header Nitro receives to the SSR-invoked fetch request