fixed api variable

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Sven laptop
2026-05-06 14:39:37 +02:00
parent a091ef9c37
commit c7874f2678
+13 -2
View File
@@ -1,8 +1,19 @@
import axios from 'axios' import axios from 'axios'
const RUNTIME = typeof window !== 'undefined' && window.__ENV__ ? window.__ENV__ : {} const RUNTIME = typeof window !== 'undefined' && window.__ENV__ ? window.__ENV__ : {}
const AUTH_API = RUNTIME.AUTH_API || import.meta.env.VITE_AUTH_API || 'http://localhost:5000'
const TRANSIT_API = RUNTIME.TRANSIT_API || import.meta.env.VITE_TRANSIT_API || 'http://localhost:5001' const normalizeApiBaseUrl = (value, fallbackPath) => {
const rawValue = value || ''
if (!rawValue) return fallbackPath
if (/^https?:\/\//i.test(rawValue) || rawValue.startsWith('//') || rawValue.startsWith('/')) {
return rawValue
}
return `${window.location.protocol}//${rawValue}`
}
const AUTH_API = normalizeApiBaseUrl(RUNTIME.AUTH_API || import.meta.env.VITE_AUTH_API, 'http://localhost:5000')
const TRANSIT_API = normalizeApiBaseUrl(RUNTIME.TRANSIT_API || import.meta.env.VITE_TRANSIT_API, 'http://localhost:5001')
export const authClient = axios.create({ baseURL: AUTH_API }) export const authClient = axios.create({ baseURL: AUTH_API })
export const transitClient = (token) => axios.create({ export const transitClient = (token) => axios.create({