Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authMiddleware stop working as of 2.0.0! #42

Closed
carlrosell opened this issue Mar 20, 2017 · 2 comments
Closed

authMiddleware stop working as of 2.0.0! #42

carlrosell opened this issue Mar 20, 2017 · 2 comments

Comments

@carlrosell
Copy link

carlrosell commented Mar 20, 2017

I noticed that the auth middleware just stopped working when updating to v2.0.0.

Here is the working config that was used before:

export const networkLayer = (store: Store<*, *>): RelayNetworkLayer =>
  new RelayNetworkLayer(
    [
      urlMiddleware({ url: graphQLURL }),
      authMiddleware({
        token: () => store.getState().auth.accessToken,
        tokenRefreshPromise: () => refreshToken(store.dispatch),
      }),
      next =>
        req => {
          req.headers['X-Stats-Timeout'] = statisticsTimeout;
          return next(req);
        },
    ],
    { disableBatchQuery: true },
  );

I then removed the batchQuery config as it was moved to another middleware but the auth middleware stopped working. It crashes on the, recently added, thrown error inside of the fetchWithMiddlewares-function https://github.com/nodkz/react-relay-network-layer/blob/master/src/fetchWithMiddleware.js#L25.

By throwing there the 401 error does not reach the 401 check inside of the authMiddleweare.

If you need more info just let me know 😄

@nodkz nodkz closed this as completed in 87f2b87 Mar 20, 2017
@nodkz
Copy link
Collaborator

nodkz commented Mar 20, 2017

Thanks for reporting.
Please check new version. Should be published in a couple of minutes.

@carlrosell
Copy link
Author

That was fast 👍 Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants