Auth0 Home Blog Docs

onRedirectCallback in React-SPA doesn't redirect to original link

Hello! I currently have an Auth0 SPA React application, which I made following this tutorial: https://auth0.com/docs/quickstart/spa/react

After having the code exactly like this, with the Auth0Provider wrapping a Routes component, when the user logs in, it always redirects to the landing page of my web application. Any help is much appreciated!
Here my wrapping code, the Auth0Provider code is exactly how it is in the tutorial.

import ReactDOM from "react-dom";
import React from "react";
//Notifications throughout application
import ReactNotification from 'react-notifications-component'

import 'react-notifications-component/dist/theme.css'
import { Auth0Provider } from "./Authorization/react-auth0-wrapper";
import { AUTH_CONFIG } from "./Authorization/auth0-variables";
import { MakeMainRoutes } from "./routes";
require('dotenv').config();

// A function that routes the user to the right place
// after login
const onRedirectCallback = appState => {
    window.history.replaceState(
      {},
      document.title,
      appState && appState.targetUrl
        ? appState.targetUrl
        : window.location.pathname
    );
  };
ReactDOM.render(
    <Auth0Provider
      domain={AUTH_CONFIG.domain}
      client_id={AUTH_CONFIG.clientId}
      redirect_uri={window.location.origin}
      onRedirectCallback={onRedirectCallback}
  >

      <ReactNotification />

      <MakeMainRoutes />

    </Auth0Provider>,

    document.getElementById("root")

  );