Backend domains
Dev and production backend domain resolution in packages/auth-client.
The frontend supports two backend targets:
| Backend target | Web origin | Auth origin | API origin |
|---|---|---|---|
| Dev | todayai.dev | auth.todayai.dev | api.todayai.dev |
| Production | today.ai | auth.today.ai | api.today.ai |
Local next dev and Vercel preview builds use the dev backend. Production
builds use the production backend.
The mapping lives in
packages/auth-client/src/urls.ts:
export const DOMAINS: Record<AppEnvironment, string> = {
development: 'todayai.dev',
preview: 'todayai.dev',
production: 'today.ai',
}Resolvers
resolveDomain(env?) // 'todayai.dev' / 'today.ai'
resolveAuthBaseUrl(env?) // 'https://auth.<domain>'
resolveApiBaseUrl(env?) // 'https://api.<domain>'
resolveAppBaseUrl(env?) // 'https://<domain>'Each resolver checks for an explicit env override before falling back to the computed default:
export function resolveAuthBaseUrl(env?: Env): string {
if (env) {
return (
env.OIDC_INTERNAL_AUTHORITY ||
env.NEXT_PUBLIC_OIDC_AUTHORITY ||
`https://auth.${resolveDomain(env)}`
)
}
return (
process.env.OIDC_INTERNAL_AUTHORITY ||
process.env.NEXT_PUBLIC_OIDC_AUTHORITY ||
`https://auth.${resolveDomain()}`
)
}OIDC_INTERNAL_AUTHORITY remains available for server-to-server auth routing,
but local web development should point it at the deployed dev auth backend.
Environment Detection
if (NODE_ENV === 'development') return 'development'
if ((VERCEL_ENV ?? NEXT_PUBLIC_VERCEL_ENV) === 'production') return 'production'
return 'preview'development and preview both resolve to the dev backend. production
resolves to the production backend.
Related
Debugging tools
The Cmd+. overlay, react-scan, the layout outline, and the agentation tracer — when each one is the right tool.
Environment variables
How env vars flow through Next.js in this repo — `.env` file layout, the `NEXT_PUBLIC_*` inlining rule that breaks our shared utilities if violated, the three-tier domain values, and the variable reference.