# React/GraphQL app calls /authorize on every single page load, and takes \> 1 second each time

**URL:** <https://community.auth0.com/t/react-graphql-app-calls-authorize-on-every-single-page-load-and-takes-1-second-each-time/101174>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [February 23, 2023, 7:21pm UTC](https://community.auth0.com/t/react-graphql-app-calls-authorize-on-every-single-page-load-and-takes-1-second-each-time/101174 "2023-02-23T19:21:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yusuf1](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@yusuf1](https://community.auth0.com/u/yusuf1)\
**Post date:** [February 23, 2023, 7:21pm UTC](https://community.auth0.com/t/react-graphql-app-calls-authorize-on-every-single-page-load-and-takes-1-second-each-time/101174/1 "2023-02-23T19:21:18Z")

</div>

I’ve built a React app running against a GraphQL/NodeJS API. I’m using the `@auth0/auth0-react` package.

In my `App.js` file I verify that the Auth0 SDK has been initialized before rendering the app. But on each refresh my app makes a call to the `/authorize` endpoint, which usually takes ~1.8 seconds.

Is there a reason why this call needs to be made on every single page load? Should it be faster?

`App.js` code shown below. Let me know if you need more info. Any help is appreciated 🙂

```auto
import { useAuth0 } from '@auth0/auth0-react';
...
const App = () => {
  const { isLoading } = useAuth0();
  console.log('in App! Loading: ', isLoading);

// Only render the app once the Auth0 SDK has finished loading
// ***This is where the latency comes. It is in a 'loading' state for 1.8 seconds while /authorize is called, which happens on every page load***
  if (isLoading) {
    return <LoadingIndicator />;
  }

  return (
    <ApolloProviderWithToken>
      <StyledEngineProvider injectFirst>
        <ThemeProvider theme={Styles}>
          <Routes>
            <Route
              path='/'
              element={
                <Navigate
                  to={Paths.home}
                  replace
                />
              }
            />
            <Route
              exact
              path={Paths.profile}
              element={<AuthenticationGuard component={Profile} />}
            />
          </Routes>
        </ThemeProvider>
      </StyledEngineProvider>
    </ApolloProviderWithToken>
  );
};

```

---

<div class="post-metadata">

**Author:** ![yusuf1](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@yusuf1](https://community.auth0.com/u/yusuf1)\
**Post date:** [February 23, 2023, 9:22pm UTC](https://community.auth0.com/t/react-graphql-app-calls-authorize-on-every-single-page-load-and-takes-1-second-each-time/101174/2 "2023-02-23T21:22:22Z")

</div>

Edit: I fixed this issue. I needed to add the following flag to my `<Auth0Provider>` instance:

`cacheLocation='localstorage'`

Now it doesn’t call `/authorize` on every load, and its lightning quick!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 24, 2023, 8:37am UTC](https://community.auth0.com/t/react-graphql-app-calls-authorize-on-every-single-page-load-and-takes-1-second-each-time/101174/3 "2023-02-24T08:37:06Z")

</div>

Wohoooo! Glad you made it! Thanks for sharing it with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 10, 2023, 8:37am UTC](https://community.auth0.com/t/react-graphql-app-calls-authorize-on-every-single-page-load-and-takes-1-second-each-time/101174/4 "2023-03-10T08:37:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
