From 3f9b14e3c1d7f47d9b3e48b94b3b5bf2c722205e Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Tue, 15 May 2018 22:15:36 -0400 Subject: migrate to cookies for jwt --- frontend/lib/withData.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'frontend/lib') diff --git a/frontend/lib/withData.js b/frontend/lib/withData.js index 9f7c2a8..0696333 100644 --- a/frontend/lib/withData.js +++ b/frontend/lib/withData.js @@ -6,15 +6,16 @@ import { LOCAL_STATE_QUERY } from '../queries/queries.graphql'; const client = new ApolloClient({ uri: process.env.NODE_ENV === 'development' ? 'http://localhost:4444' : 'http://localhost:4444', ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once) - request: operation => { - // if we're in the client and the user has a token, send it along with the request - if (typeof localStorage !== 'undefined' && localStorage.getItem('token')) { - operation.setContext({ - headers: { - authorization: `Bearer ${localStorage.getItem('token')}`, - }, - }); - } + // TODO this is a bug: https://github.com/apollographql/apollo-client/issues/3265 + fetchOptions: { + credentials: 'include', + }, + request: async operation => { + operation.setContext({ + fetchOptions: { + credentials: 'include', + }, + }); }, clientState: { resolvers: { -- cgit v1.3