Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR server forwarding cookies to apollo server?

See original GitHub issue

Issue Description

This is a following issue from

I am using vue-cli-plugin-ssr together with vue-cli-plugin-apollo and try to achieve proper SSR which prefetch data from the apollo server according to the authentication jwt from cookie.

My ssr server runs on localhost:8000 and apollo server runs on localhost:4000.

After using cookie instead of http request headers to pass the jwt to the ssr server, I can see the cookie is successfully passed to the ssr server:


But when the ssr server prefetches from the apollo server via its own http request, I can see it passes no cookie to it, therefore the prefetch is still no properly authenticated.

So now the problem is how to forward this cookie from the ssr server to the apollo server. The source code creating the ssr server here ( provides no interface to inject express middleware like cookie-parser, and I also couldn’t find a way to export from here the express req object, which I believe is necessary in my entry-server.js file to customize the server-side ApolloProvider.

Any suggestions about that?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

Akryumcommented, Sep 26, 2018

When I have some spare time 😸

jeisslercommented, Apr 11, 2019

@beeplin @zickat I’m having a similar issue trying to achieve proper ssr using vue-cli-plugin-apollo and vue-cli-plugin-ssr. Obviously it’s using localstorage by default which I have overridden in vue-apollo.js getAuth option, so that is using cookies now… My confusion is how to then ‘customize’ apolloProvider inside entry-server.js to use the jwt from the cookie? I’ve found very little information outside of this ticket and the one other linked ticket about this although it seems it would be a common use case in ssr. Many thanks if someone can please elaborate a bit on how to achieve this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side rendering - Apollo GraphQL Docs
Server -side rendering (SSR) is a performance optimization for modern web apps. It enables you to render your app's initial state to raw...
Read more >
Send request with cookie from apollo client with Next.js #5089
I'm using graphql yoga as my server. This works fine in localhost but in production the cookie is not being sent in ssr....
Read more >
Next Apollo Client Not Sending Cookies - Stack Overflow
Do you make GraphQL requests in the backend e.g. to server side render certain views? I think you would have to forward the...
Read more >
Accessing Authorization headers in Apollo graphql client
In case there is no sessionId, the graphql-server will issue a new ... header is set and if yes, store the sessionId in...
Read more >
Authentication for NextJS with GraphQL & REST APIs and ...
As a developer, I want to be able to implement SSR (Server Side ... their cookie and forward it to , even...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found