-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgatsby-browser.js
35 lines (32 loc) · 1005 Bytes
/
gatsby-browser.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
import React from "react";
import { Auth0Provider } from "@auth0/auth0-react";
import { navigate } from "gatsby";
export const onRouteUpdate = ({ location, prevLocation }) => {
// console.log('Route updated:', location, prevLocation);
setTimeout(() => {
window.scrollTo(0, 0);
// console.log('Scrolled to top');
}, 0);
};
const onRedirectCallback = (appState) => {
// Use Gatsby's navigate method to replace the url
navigate(appState?.returnTo || '/', { replace: true });
};
export const wrapRootElement = ({ element }) => {
return (
<Auth0Provider
domain={'dev-y27lxavr02scmif8.us.auth0.com'}
clientId={'jclY1uHk29dMQCtQqkRPUlJI2Cd5mRwA'}
useRefreshTokens={true}
cacheLocation='localstorage'
onRedirectCallback={onRedirectCallback}
authorizationParams={{
redirect_uri: 'https://weplaydos.games',
audience: 'https://hello-world.example.com',
scope: 'openid profile email offline_access'
}}
>
{element}
</Auth0Provider>
);
};