Fix API_BASE_URL fallback to point to local backend on localhost, resolving CORS error
This commit is contained in:
+9
-1
@@ -1,6 +1,14 @@
|
||||
// Force relative paths on Netlify to route through Netlify proxy and eliminate CORS errors
|
||||
const isNetlify = typeof window !== 'undefined' && window.location.hostname.includes('netlify.app');
|
||||
const API_BASE_URL = isNetlify ? '' : (import.meta.env.VITE_API_BASE_URL || 'https://services-api.a2zhealth.in/onboarding').replace(/\/$/, '');
|
||||
const isLocalhost = typeof window !== 'undefined' && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');
|
||||
|
||||
const DEFAULT_API_URL = isNetlify
|
||||
? ''
|
||||
: isLocalhost
|
||||
? 'http://localhost:8000'
|
||||
: 'https://services-api.a2zhealth.in/onboarding';
|
||||
|
||||
const API_BASE_URL = (import.meta.env.VITE_API_BASE_URL || DEFAULT_API_URL).replace(/\/$/, '');
|
||||
|
||||
/**
|
||||
* Health check endpoint ping
|
||||
|
||||
+6
-1
@@ -2,7 +2,12 @@ import { CategoryInfo, PatientInfo, VoiceTurnResult } from "../types/voice";
|
||||
import { DocumentExtractionResult, PatientOnboardingResult } from "../types/onboarding";
|
||||
|
||||
const envUrl = import.meta.env.VITE_API_BASE_URL;
|
||||
const API_BASE_URL = (envUrl !== undefined && envUrl !== "" ? envUrl : "https://services-api.a2zhealth.in/onboarding").replace(/\/$/, "");
|
||||
const isNetlify = typeof window !== "undefined" && window.location.hostname.includes("netlify.app");
|
||||
const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1");
|
||||
|
||||
const DEFAULT_API_URL = isNetlify ? "" : isLocalhost ? "http://localhost:8000" : "https://services-api.a2zhealth.in/onboarding";
|
||||
|
||||
const API_BASE_URL = (envUrl !== undefined && envUrl !== "" ? envUrl : DEFAULT_API_URL).replace(/\/$/, "");
|
||||
|
||||
export async function startVoiceOnboarding(
|
||||
patient: PatientInfo,
|
||||
|
||||
Reference in New Issue
Block a user