How to send cookies to an external service from a server component
Unanswered
European hornet posted this in #help-forum
European hornetOP
Hello everyone, I have a problem with cookies
I have an entire external server that does all the authorization logic. I have a problem when I make a request from a server component. I complete authorization and receive an httpOnly cookie and then I want to go to the page/profile
This page requests a request/profile on an external server, and I get a 401. My cookies come when I render the nextjs page, but after that I have to pass them myself in the next request to the server. I'm doing this in axios now and don't think it's correct
It turns out like this: the user requests /profile -> the next server makes a request -> (there are no cookies here anymore) the external server returns 401
Of course, I can add a header to each request, but there may be more elegant options
axios hack
I have an entire external server that does all the authorization logic. I have a problem when I make a request from a server component. I complete authorization and receive an httpOnly cookie and then I want to go to the page/profile
This page requests a request/profile on an external server, and I get a 401. My cookies come when I render the nextjs page, but after that I have to pass them myself in the next request to the server. I'm doing this in axios now and don't think it's correct
It turns out like this: the user requests /profile -> the next server makes a request -> (there are no cookies here anymore) the external server returns 401
Of course, I can add a header to each request, but there may be more elegant options
axios hack
1 Reply
European hornetOP