mirror of
https://github.com/hanzoai/billing.git
synced 2026-10-30 18:46:54 +00:00
IAM DB has hanzo-billing, lux-app, zoo-app, pars-app but code used app-hanzo, app-lux, app-zoo, app-pars which don't exist. Co-authored-by: Hanzo Dev <[email protected]>
25 lines
778 B
TypeScript
25 lines
778 B
TypeScript
import type { IamAuthConfig } from './iam-auth'
|
|
import type { BillingOrgConfig } from './config'
|
|
|
|
function getBasePath(): string {
|
|
if (typeof window === 'undefined') return ''
|
|
// Detect basePath from current URL (handles GitHub Pages /billing/ prefix)
|
|
const path = window.location.pathname
|
|
// If path starts with /billing, we're on GitHub Pages
|
|
if (path.startsWith('/billing')) return '/billing'
|
|
return ''
|
|
}
|
|
|
|
export function makeAuthConf(org: BillingOrgConfig): IamAuthConfig {
|
|
const basePath = getBasePath()
|
|
return {
|
|
iamServerUrl: org.iamServerUrl,
|
|
clientId: org.iamClientId,
|
|
redirectUri: typeof window !== 'undefined'
|
|
? `${window.location.origin}${basePath}/auth/callback`
|
|
: '',
|
|
orgName: org.id,
|
|
appName: org.iamClientId,
|
|
}
|
|
}
|