I am trying to fetch some data via Apollo Client during SSR in the NextJS getServerSideProps
method from an external graphql server.
The server response has a Set-Cookie
header with a session id.
Later on, however, I also want to send queries from the client side to the same external grahpql server, but the Set-Cookie
header received in the getServerSideProps
is not passed to the browser, so the graphlq server has no clue that this still should be the same session.
Is there a way to automatically pass the Set-Cookie
received during SSR to the browser and later automatically use the cookie from the browser during subsequent SSR queries?
Essentially using SSR as a pass-through between the browser and the external server.
Additional info: CORS is enabled on the graphql server, they are all on the same domain, credentials: 'same-origin'
is set on the apollo client and thus there isn't any cors related issue
I've tried using the next-cookie
package to set already existing broswer cookies for the apollo-client queries during SSR, however, I haven't been able to pass the Set-Cookie
received during SSR to the browser.