2024-08-06 13:59:08 +00:00
|
|
|
import type { Auth0ClientOptions, CacheLocation } from '@auth0/auth0-spa-js'
|
2024-02-05 16:48:02 +01:00
|
|
|
|
|
|
|
|
interface EnvConfig {
|
|
|
|
|
name: string
|
|
|
|
|
apiUrl: string
|
|
|
|
|
auth: Auth0ClientOptions
|
|
|
|
|
dev: boolean
|
|
|
|
|
tracesSampleRate: number
|
2025-06-13 15:21:27 +02:00
|
|
|
grafanaUrl: string
|
2024-02-05 16:48:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
tracesSampleRate: 1.0,
|
2025-06-13 15:21:27 +02:00
|
|
|
grafanaUrl: '',
|
2024-02-05 16:48:02 +01:00
|
|
|
}
|
|
|
|
|
case 'dancefinder.unbound.se':
|
|
|
|
|
return {
|
|
|
|
|
name: 'production',
|
|
|
|
|
apiUrl: 'https://dancefinder.unbound.se/query',
|
|
|
|
|
auth: prod,
|
|
|
|
|
dev: false,
|
|
|
|
|
tracesSampleRate: 1.0,
|
2025-06-13 15:21:27 +02:00
|
|
|
grafanaUrl: 'https://faro-collector-prod-eu-west-0.grafana.net/collect/532676b975308d70605d856635721a61',
|
2024-02-05 16:48:02 +01:00
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
throw new Error(`unexpected host: ${host}`)
|
|
|
|
|
}
|
|
|
|
|
}
|