export const API_ORIGIN = 'https://plate.richarjiang.com'; export const API_BASE_PATH = '/api'; export function buildApiUrl(path: string): string { const normalizedPath = path.startsWith('/') ? path : `/${path}`; // 如果传入的路径已包含 /api 前缀,则直接拼接域名;否则自动补上 /api const finalPath = normalizedPath.startsWith(`${API_BASE_PATH}/`) ? normalizedPath : `${API_BASE_PATH}${normalizedPath}`; return `${API_ORIGIN}${finalPath}`; }