fix: 移除所有硬编码的localhost:8080,使用相对路径

- 创建utils/config.ts集中管理API_BASE和文件URL
- 删除.env文件(VITE_SERVER_API_URL=http://localhost:8080)
- env.ts默认API前缀改为/api/v1匹配后端路由
- 替换16处硬编码的localhost:8080引用
This commit is contained in:
2026-05-03 19:48:07 +08:00
parent 6d5d1922f5
commit fbc2e5ac91
17 changed files with 32 additions and 37 deletions
+8
View File
@@ -0,0 +1,8 @@
export const API_BASE = import.meta.env.VITE_API_BASE_URL || '/api/v1'
export function getFileUrl(path: string): string {
if (!path) return ''
if (path.startsWith('http')) return path
const base = import.meta.env.VITE_API_BASE || ''
return `${base}${path}`
}
+1 -1
View File
@@ -10,7 +10,7 @@ import { z } from 'zod'
const EnvSchema = z.object({
VITE_SERVER_API_URL: z.string().default(''),
VITE_SERVER_API_PREFIX: z.string().default('/api'),
VITE_SERVER_API_PREFIX: z.string().default('/api/v1'),
VITE_SERVER_API_TIMEOUT: z.coerce.number().default(5000),
})