I'm following this guide https://developer.okta.com/quickstart/ to add authentication to my React App. I've set everything as per the guide, and I get the id token from the demo preview site. The log says the authentication is successful and provides an id token back. This is how the redirect looks like.
On the redirect I get this error: Cannot GET /implicit/callback
displayed in the browser. Where did I go wrong?
This is how my index.js looks like in React:
import { Security, SecureRoute, ImplicitCallback } from '@okta/okta-react';
ReactDOM.render((
<HashRouter>
<Switch>
<Security issuer={config.issuer}
client_id={config.clientId}
redirect_uri={config.redirect_uri} >
<Route path='/' exact={true} component={Full}/>
<Route path='/implicit/callback' component={ImplicitCallback} />
</Security>
</Switch>
</HashRouter>
), document.getElementById('root'));
I think it might have something to do with HashRouter and CoreUI but I don't know what exactly is the problem as I can get it running with the normal create-react-app template.
LoginCallback handles the callback after the redirect to and back from the Okta-hosted login page. By default, it parses the tokens from the uri, stores them, then redirects to / . If a SecureRoute caused the redirect, then the callback redirects to the secured route.
It was an issue with Webpack.
Setting devServer.historyApiFallback: true
and output.publicPath: '/'
in webpack config fixed the issue.
HashRouter still didn't work, had to use BrowserRouter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With