Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
ReactJS: Okta Auth RestoreOriginalUri Function not Redirecting

I've been stumped on this issue for quite some time.

I am using Okta Authentication for my React SPA and everything is going well however the restoreOriginalUri function doesn't actually route/redirect back to the Original URI on successful authentication.

package.json

    "@okta/okta-auth-js": "^5.6.0",
    "@okta/okta-react": "^6.2.0",
    "@okta/okta-signin-widget": "^5.8.1",

Code:

    <Security
      oktaAuth={oktaAuth}
      onAuthRequired={customAuthHandler}
      restoreOriginalUri={restoreOriginalUri} // not working
    >
      <Switch>
        <Provider store={store}>
          <Route exact path="/" component={Home} />
          <Route exact path="/reports" component={Reports} />
        </Provider>
      </Switch>
    </Security>
// restoreOriginalUri function

  const restoreOriginalUri = async (_oktaAuth, originalUri) => {
    console.log("restoring original uri...");
    history.replace(toRelativeUrl(originalUri, window.location.origin));
  };

Error message: enter image description here

I know for a fact that the authentication was successful as once I receive the error message and refresh the browser page, im able to navigate to my protected routes and see user identity via scopes without being forced to /login

Any ideas?

TIA

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try changing your restorOriginalUri const to the following:

const restoreOriginalUri = async (oktaAuth, originalUri) => {
  history.replace(toRelativeUrl(originalUri || '/', window.location.origin));
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!