This commit is contained in:
Dagimassefa
2026-06-22 12:29:48 +03:00
parent 911f486620
commit b3bfa899f5
6 changed files with 43 additions and 14 deletions

View File

@@ -1,4 +1,10 @@
// API host is env-driven (set VITE_API_URL per environment, e.g. the remote
// https://edrfreightapi.triaplc.com for prod). Falls back to the local API for dev.
export const API_BASE_URL =
(import.meta.env.VITE_API_URL as string | undefined) ?? 'http://localhost:3001';
// Accept either a host-only URL or one that already ends with `/api`.
// The HTTP client appends `/api` itself, so we normalize here to avoid
// accidental `/api/api/...` requests from env values.
const rawApiBaseUrl =
(import.meta.env.VITE_API_URL as string | undefined) ?? "http://localhost:3001";
export const API_BASE_URL = rawApiBaseUrl
.trim()
.replace(/\/+$/, "")
.replace(/\/api$/, "");