question-mark
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.

Apollo Client does not pass cookies

See original GitHub issue

I am currently using nextJS with apollo and it’s completely unusable for me because the cookie is not passing in every request.

I would be much grateful if someone can just point me to right direction to pass cookies properly.

Even the apollo nextjs example is buggy itself https://github.com/adamsoffer/next-apollo-example

Even in that example, cookies are not being sent in the request.

I am trying every possible way of setting cookies in config without success.

Some people say swapping ApolloClient to ApolloBoost have solved it but neither of the packages work for me.

Below is an example of what I have tried

new ApolloClient({
        connectToDevTools: process.browser,
        ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once)
        link: new HttpLink({
            uri: APOLLO_ENDPOINT, // Server URL (must be absolute)
            opts:{
                credentials:'include'
            },
            credentials: 'include', // Additional fetch() options like `credentials` or `headers`,
        }),
        cache: new InMemoryCache().restore(initialState || {}),
        fetchOptions:{
            credentials:'include'
        },
        credentials:'include'
    })

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:44
  • Comments:89 (2 by maintainers)

github_iconTop GitHub Comments

79reactions
antenandocommented, Dec 11, 2018

Figured it out. credentials:'include' should be in the root of the config. Like,

new ApolloClient({
  credentials: 'include',
})

I was using inside of fetchOptions

19reactions
RiChrisMurphycommented, Jan 26, 2019

I’m pretty sure I’m still having this issue. My rest calls have cookies attached, however my graphql queries don’t.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cookie not shown/stored in the browser - Help - Apollo GraphQL
Hi,. I have a question regarding cookies. Here I'm using apollo-server-express, express-session and redis for all of the authentication ...
Read more >
React Apollo Client not sending cookies - Stack Overflow
This is saying its safe to send along cookies whenever it makes a query to the backend server. So you take this networkInterface...
Read more >
apollo client 3 not setting cookies in the browser : r/graphql
I have a MERNG app that is using apollo server w/ express-session (redis for now). in the response header.
Read more >
GraphQL, Apollo Studio, and Cookies - Dev Genius
Scenario #1: Apollo Studio connects to your NodeJS GraphQL server, but cookies are not passed. Scenario #2: Apollo Studio refuses to connect ...
Read more >
Next.js With Apollo, SSR, Cookies, and Typescript
Newer browsers will prevent you to set third-party cookies if you don't mark them as SameSite=None and Secure . You will need to...
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 Hashnode Post

No results found