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

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 :slight_smile:

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 (
      <StyledEngineProvider injectFirst>
        <ThemeProvider theme={Styles}>
              element={<AuthenticationGuard component={Profile} />}

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


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

1 Like

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

1 Like

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