diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-15 22:15:36 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-15 22:15:36 -0400 |
| commit | 3f9b14e3c1d7f47d9b3e48b94b3b5bf2c722205e (patch) | |
| tree | 63373ce8c75e51305b7899af6c53903ef6c4f179 /frontend/lib/withData.js | |
| parent | ae1a94b08f5aba0c16c6536e388b4dd4a53120fd (diff) | |
migrate to cookies for jwt
Diffstat (limited to 'frontend/lib/withData.js')
| -rw-r--r-- | frontend/lib/withData.js | 19 |
1 files changed, 10 insertions, 9 deletions
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: { |
