Hi,
following code is working it is showing my company’s login page while going to application pages in browser. but once I login it redirects to “/login” page and it is blank.
it is not redirecting to original application page that was accessed.
Please let me know I am stuck and do not understand what is going on.
CODE Snippet
import React, { Component } from ‘react’;
import { BrowserRouter, Route,useNavigate } from ‘react-router-dom’;
import { Security, SecureRoute, LoginCallback } from ‘@okta/okta-react’;
import { OktaAuth, toRelativeUrl } from ‘@okta/okta-auth-js’;
import { Home } from ‘./components/Home’;
import App1 from ‘./survey-app/App1’;
import App2 from ‘./survey-app/App2’;
import App3 from ‘./survey-app/App3’;
import { config } from ‘./config/config’;
import ‘./custom.css’;
const SecureRouteLinks = (props) => {
return (
<SecureRoute path=‘/page2’ render={(props) => <App2 {…props} SurveyType={“One”} />} />
<SecureRoute path=‘/page3’ render={(props) => <App2 {…props} SurveyType={“Two”} />} />
);
}
export default class App extends Component {
static displayName = App.name;
constructor(props) {
super(props);
this.oktaAuth = new OktaAuth({…config});
this.restoreOriginalUri = async (_oktaAuth, originalUri) => {
const navigate = useNavigate();
//props.history.replace(toRelativeUrl(originalUri || '/', window.location.origin));
navigate(toRelativeUrl(originalUri || '/', window.location.origin));
};
}
render() {
return (
<BrowserRouter>
{
<SecureRouteLinks oktaAuthObj={this.oktaAuth } restoreOriginalUrl={this.restoreOriginalUri} />
}
</BrowserRouter>
);
}
}