feat: Oracle CRM Page, Synthetic Client Data and Live Snapshot when hitting emotion hotpoint
This commit is contained in:
@@ -19,8 +19,29 @@ import type {
|
||||
} from '../types/canvas';
|
||||
import { VELOCITY_TOKEN_KEY } from '@/lib/velocityPlatformClient';
|
||||
|
||||
const BASE_URL = (import.meta.env.VITE_ORACLE_API_URL as string | undefined) ?? '';
|
||||
const WS_URL = (import.meta.env.VITE_ORACLE_WS_URL as string | undefined) ?? '';
|
||||
function getBrowserOrigin(): string {
|
||||
return typeof window !== 'undefined' ? window.location.origin : '';
|
||||
}
|
||||
|
||||
function resolveBaseUrl(): string {
|
||||
const configured = (import.meta.env.VITE_ORACLE_API_URL as string | undefined)?.trim();
|
||||
if (configured) {
|
||||
return configured.replace(/\/$/, '');
|
||||
}
|
||||
return getBrowserOrigin();
|
||||
}
|
||||
|
||||
function resolveWsUrl(): string {
|
||||
const configured = (import.meta.env.VITE_ORACLE_WS_URL as string | undefined)?.trim();
|
||||
if (configured) {
|
||||
return configured.replace(/\/$/, '');
|
||||
}
|
||||
const origin = getBrowserOrigin();
|
||||
return origin ? origin.replace(/^http/, 'ws') : '';
|
||||
}
|
||||
|
||||
const BASE_URL = resolveBaseUrl();
|
||||
const WS_URL = resolveWsUrl();
|
||||
|
||||
function apiUrl(path: string): string {
|
||||
return `${BASE_URL}/api/oracle/v1${path}`;
|
||||
@@ -30,10 +51,6 @@ async function apiFetch<T>(
|
||||
path: string,
|
||||
options?: RequestInit & { idempotencyKey?: string },
|
||||
): Promise<T> {
|
||||
if (!BASE_URL) {
|
||||
throw new Error('Oracle API is not configured. Set VITE_ORACLE_API_URL to a live backend.');
|
||||
}
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Oracle-Contract-Version': 'v1',
|
||||
|
||||
Reference in New Issue
Block a user