Files
dancefinder-app/utils/environment.ts
T

56 lines
1.4 KiB
TypeScript

import { type Auth0ClientOptions, type CacheLocation } from '@auth0/auth0-spa-js'
interface EnvConfig {
name: string
apiUrl: string
auth: Auth0ClientOptions
dev: boolean
sentryEnabled: boolean
tracesSampleRate: number
replaysSessionSampleRate: number
replaysOnErrorSampleRate: number
}
export const envConfig = (host: string): EnvConfig => {
const options = {
useRefreshTokens: true,
cacheLocation: 'localstorage' as CacheLocation,
authorizationParams: {
audience: 'http://dancefinder.unbound.se',
redirect_uri: window.location.origin,
},
}
const prod = {
...options,
domain: 'unbound.eu.auth0.com',
clientId: 'orQfnvCPUR5C3mJkKoiWLQHOVQsBn60e',
}
switch (host) {
case 'localhost':
return {
name: 'development',
apiUrl: 'http://localhost:6080/query',
auth: prod,
dev: true,
sentryEnabled: false,
tracesSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
}
case 'dancefinder.unbound.se':
return {
name: 'production',
apiUrl: 'https://dancefinder.unbound.se/query',
auth: prod,
dev: false,
sentryEnabled: true,
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
}
default:
throw new Error(`unexpected host: ${host}`)
}
}