refactor(web): deduplicate getBaseUrl() — export from auth-api.ts, import in auth-context.tsx
This commit is contained in:
parent
f80602d2b1
commit
8ef44788e1
@ -10,7 +10,7 @@ import { createAuthClient, type AuthClient } from '@bytelyst/auth-client';
|
|||||||
|
|
||||||
export const PRODUCT_ID = 'chronomind';
|
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__) {
|
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 (window as unknown as Record<string, unknown>).__PLATFORM_URL__ as string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { createAuthProvider } from '@bytelyst/react-auth';
|
import { createAuthProvider } from '@bytelyst/react-auth';
|
||||||
import { setSyncEnabled } from './platform-sync';
|
import { setSyncEnabled } from './platform-sync';
|
||||||
import { PRODUCT_ID, getAuthClient } from './auth-api';
|
import { PRODUCT_ID, getAuthClient, getBaseUrl } from './auth-api';
|
||||||
|
|
||||||
interface ChronoMindUser {
|
interface ChronoMindUser {
|
||||||
id: string;
|
id: string;
|
||||||
@ -18,13 +18,6 @@ interface ChronoMindUser {
|
|||||||
[key: string]: unknown;
|
[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>({
|
const { AuthProvider: _AuthProvider, useAuth: _useAuth } = createAuthProvider<ChronoMindUser>({
|
||||||
baseUrl: getBaseUrl(),
|
baseUrl: getBaseUrl(),
|
||||||
storagePrefix: 'chronomind',
|
storagePrefix: 'chronomind',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user