File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import { createRoot } from "react-dom/client" ;
3
- import { Router } from "react-router-dom" ;
3
+ import { Router , withRouter } from "react-router-dom" ;
4
4
import { createTheme , ThemeProvider } from "@material-ui/core" ;
5
5
6
6
// @ts -ignore
7
- import { OktaAuth } from "@okta/okta-auth-js" ;
7
+ import { OktaAuth , toRelativeUrl } from "@okta/okta-auth-js" ;
8
8
import { Security } from "@okta/okta-react" ;
9
9
import { history } from "./utils/historyUtils" ;
10
10
import AppOkta from "./containers/AppOkta" ;
@@ -25,13 +25,23 @@ if (process.env.VITE_OKTA) {
25
25
clientId : process . env . VITE_OKTA_CLIENTID ,
26
26
redirectUri : window . location . origin + "/implicit/callback" ,
27
27
} ) ;
28
+
29
+ const AppWithRouter = withRouter ( ( { history } ) => {
30
+ const restoreOriginalUri = ( _oktaAuth , originalUri ) =>
31
+ history . replace ( toRelativeUrl ( originalUri || "/" , window . location . origin ) ) ;
32
+
33
+ return (
34
+ < Security oktaAuth = { oktaAuth } restoreOriginalUri = { restoreOriginalUri } >
35
+ < AppOkta />
36
+ </ Security >
37
+ ) ;
38
+ } ) ;
39
+
28
40
/* istanbul ignore next */
29
41
root . render (
30
42
< Router history = { history } >
31
43
< ThemeProvider theme = { theme } >
32
- < Security oktaAuth = { oktaAuth } >
33
- < AppOkta />
34
- </ Security >
44
+ < AppWithRouter />
35
45
</ ThemeProvider >
36
46
</ Router >
37
47
) ;
You can’t perform that action at this time.
0 commit comments