forked from cypress-io/cypress-realworld-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.auth0.tsx
45 lines (41 loc) · 1.26 KB
/
index.auth0.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from "react";
import { createRoot } from "react-dom/client";
import { Router } from "react-router-dom";
import { createTheme, ThemeProvider } from "@material-ui/core";
import { Auth0Provider } from "@auth0/auth0-react";
import AppAuth0 from "./containers/AppAuth0";
import { history } from "./utils/historyUtils";
const theme = createTheme({
palette: {
secondary: {
main: "#fff",
},
},
});
/* istanbul ignore next */
const onRedirectCallback = (appState: any) => {
history.replace((appState && appState.returnTo) || window.location.pathname);
};
const root = createRoot(document.getElementById("root")!);
/* istanbul ignore if */
if (process.env.VITE_APP_AUTH0) {
root.render(
<Auth0Provider
domain={process.env.VITE_APP_AUTH0_DOMAIN!}
clientId={process.env.VITE_APP_AUTH0_CLIENTID!}
redirectUri={window.location.origin}
audience={process.env.VITE_APP_AUTH0_AUDIENCE}
scope={process.env.VITE_APP_AUTH0_SCOPE}
onRedirectCallback={onRedirectCallback}
cacheLocation="localstorage"
>
<Router history={history}>
<ThemeProvider theme={theme}>
<AppAuth0 />
</ThemeProvider>
</Router>
</Auth0Provider>
);
} else {
console.error("Auth0 is not configured.");
}