refactor(web): deduplicate getBaseUrl() — export from auth-api.ts, import in auth-context.tsx

This commit is contained in:
saravanakumardb1 2026-02-28 12:11:26 -08:00
parent f80602d2b1
commit 8ef44788e1
2 changed files with 2 additions and 9 deletions

View File

@ -10,7 +10,7 @@ import { createAuthClient, type AuthClient } from '@bytelyst/auth-client';
export const PRODUCT_ID = 'chronomind';
function getBaseUrl(): string {
export function getBaseUrl(): string {
if (typeof window !== 'undefined' && (window as unknown as Record<string, unknown>).__PLATFORM_URL__) {
return (window as unknown as Record<string, unknown>).__PLATFORM_URL__ as string;
}

View File

@ -6,7 +6,7 @@
import { createAuthProvider } from '@bytelyst/react-auth';
import { setSyncEnabled } from './platform-sync';
import { PRODUCT_ID, getAuthClient } from './auth-api';
import { PRODUCT_ID, getAuthClient, getBaseUrl } from './auth-api';
interface ChronoMindUser {
id: string;
@ -18,13 +18,6 @@ interface ChronoMindUser {
[key: string]: unknown;
}
function getBaseUrl(): string {
if (typeof window !== 'undefined' && (window as unknown as Record<string, unknown>).__PLATFORM_URL__) {
return (window as unknown as Record<string, unknown>).__PLATFORM_URL__ as string;
}
return process.env.NEXT_PUBLIC_PLATFORM_SERVICE_URL ?? 'https://api.chronomind.app';
}
const { AuthProvider: _AuthProvider, useAuth: _useAuth } = createAuthProvider<ChronoMindUser>({
baseUrl: getBaseUrl(),
storagePrefix: 'chronomind',