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.

Add docs about how to pass a session cookie

See original GitHub issue

Hey @stubailo @jbaxleyiii

I checked out the Meteor demo and also @johnthepink PR for auth middleware. For SPA’s this would work well, because they would need some kind of middleware to authenticate with server to share context, but if the app works in the same environment as server it would be important to share session state with server through apollo client during requests (also it’s easier). You may have seen in Relay that they allow setting headers and passing session cookie: https://facebook.github.io/relay/docs/guides-network-layer.html directly through network layer.

This approach is super simple, what you think? Is am missing anything?

Issue Analytics

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

github_iconTop GitHub Comments

19reactions
gauravtiwaricommented, Apr 20, 2016

Thanks @jbaxleyiii that makes sense. So, it’s basically same thing as Relay. For anyone else using Rails or some other framework environment,

import ApolloClient, { createNetworkInterface } from 'apollo-client';

const networkInterface = createNetworkInterface('/graphql', {
  credentials: 'same-origin',
  headers: {
    'X-CSRF-Token': "xyz",
    token: 'supersecret'
  }
});

const client = new ApolloClient({ networkInterface });
5reactions
bkeatingcommented, Feb 3, 2018

A bit late here, but as a Django / graphene-python user, I got things working only after renaming my CSRF header key from X-CSRF-Token to X-CSRFToken.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using HTTP cookies - MDN Web Docs
An HTTP cookie (web cookie, browser cookie) is a small piece of data that a ... Session cookies are deleted when the current...
Read more >
Pass Session Cookie in URL Header - Stack Overflow
Now I need to pass this session cookie in Header of another URL to get more information. The URL: http://myexperiment.org.uk/whoami.xml then ...
Read more >
Manage Session Cookies | Firebase Authentication
Firebase Auth provides server-side session cookie management for traditional websites that rely on session ... Get the ID token passed and the CSRF...
Read more >
Cookies, document.cookie - The Modern JavaScript Tutorial
Upon sign in, the server uses the Set-Cookie HTTP-header in the response to set a cookie with a unique “session identifier”.
Read more >
Turn cookies on or off - Computer - Google Account Help
In Chrome · On your computer, open Chrome. · At the top right, click More More and then Settings. · Under "Privacy and...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found