Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send credentials from SSR #290

Open
sayandedotcom opened this issue Apr 18, 2024 · 1 comment
Open

Send credentials from SSR #290

sayandedotcom opened this issue Apr 18, 2024 · 1 comment

Comments

@sayandedotcom
Copy link

sayandedotcom commented Apr 18, 2024

Send credentials from here giving error

app/ApolloWrapper.jsx file like this this

I want to send Like this const httpLink = createHttpLink({ uri: "http://localhost:8000/graphql", credentials: "include", });

Tasks

No tasks being tracked yet.
@phryneas
Copy link
Member

That's unfortunately impossible, since in that moment you are on the server and the server has no knowledge about the cookies of your Browser.

You can forward cookies from the incoming request (that calls SSR) to the outgoing request that calls your api - but you have to do so manually.

Unfortunately, this is a multi-step process as in Next.js SSR, you don't have access to cookies. So you have to get the cookies in RSC, forward them as props to your ApolloWrapper component and then add them to the outgoing request.

When transporting cookies as props, ensure to encrypt them, as otherwise they would be readable in the browser, too.
Patrick has created a great example for that over here: #281 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants