rendering app from withing an auth/http wrapper

This commit is contained in:
Carter 2024-10-23 14:22:31 -06:00
parent 47e3939112
commit 90fd2905fb
5 changed files with 74 additions and 61 deletions

View file

@ -0,0 +1,41 @@
import { Auth0Provider } from '@auth0/auth0-react'
import { or } from '../utils/types'
import AuthWrapper from '../providers/auth'
import HTTPProvider from '../providers/http'
import App from './App'
function AuthHTTPWrapper() {
let url: string | undefined = window.location.origin;
let audience: string | undefined;
if (window.location.origin === "https://staging.brandxtech.ca") {
url = import.meta.env.VITE_AUTH0_CLIENT_STAGING_DOMAIN;
audience = import.meta.env.VITE_AUTH0_STAGING_AUDIENCE;
} else {
url = import.meta.env.VITE_AUTH0_CLIENT_DOMAIN;
audience = import.meta.env.VITE_AUTH0_AUDIENCE;
}
let client_id = import.meta.env.VITE_AUTH0_BXT_CLIENT_ID;
return (
<Auth0Provider
domain={or(url, "")}
clientId={or(client_id, "")}
authorizationParams={{
audience: or(audience, ""),
redirect_uri: window.location.origin + "/callback"
}}
useRefreshTokens={true}
cacheLocation='localstorage'
>
<AuthWrapper>
<HTTPProvider>
<App/>
</HTTPProvider>
</AuthWrapper>
</Auth0Provider>
)
}
export default AuthHTTPWrapper