-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (38 loc) · 1.14 KB
/
index.js
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
// Import necessary dependencies
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { Auth0Provider } from "@auth0/auth0-react";
import history from "./utils/history";
import { getConfig } from "./config";
// Define onRedirectCallback function
const onRedirectCallback = (appState) => {
history.push(
appState && appState.returnTo ? appState.returnTo : window.location.pathname
);
};
// Get Auth0 configuration
const config = getConfig();
// Configuration for Auth0Provider
const providerConfig = {
domain: config.domain,
clientId: config.clientId,
cacheLocation: 'localstorage',
onRedirectCallback,
authorizationParams: {
redirect_uri: window.location.origin,
...(config.audience ? { audience: config.audience } : null),
},
};
// Render the app using the new client rendering API
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<Auth0Provider {...providerConfig}>
<App />
</Auth0Provider>
</React.StrictMode>
);
// Unregister service worker
serviceWorker.unregister();