sau / sau_frontend /src /utils /apiBase.js
skatef's picture
fix: 生产环境 API 同源,HF Space / Docker 前端可正常请求后端
a206d0f
raw
history blame contribute delete
393 Bytes
/**
* 生产环境前后端同源(Docker / Hugging Face Space)时请在 .env.production 中设 VITE_API_BASE_URL 为空。
* 开发环境使用 .env.development 中的 /api(Vite 代理到后端)。
*/
export function getApiBase() {
const v = import.meta.env.VITE_API_BASE_URL
if (v != null && String(v).trim() !== '') {
return String(v).replace(/\/$/, '')
}
return ''
}