Files
lotteryAdmin/src/lib/lottery-api-base.ts
kang 671c737781 refactor(env, i18n, http): 更新环境配置与错误提示信息
修改 .env.example,简化 API 配置说明并明确生产环境要求。更新多语言错误提示,确保用户在未启用 API 代理时获得清晰反馈。重构 admin-http.ts,优化 API 基础 URL 的解析逻辑,提升代码可维护性。
2026-05-29 11:48:13 +08:00

20 lines
678 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const DEFAULT_LOTTERY_API_ORIGIN = "http://127.0.0.1:8000";
/** Laravel 根地址(无尾部 `/`),仅供 Next 本地开发代理使用。 */
export function lotteryApiOrigin(): string {
const configured =
process.env.LOTTERY_API_UPSTREAM?.trim() ||
process.env.NEXT_PUBLIC_LOTTERY_API_BASE_URL?.trim();
return (configured || DEFAULT_LOTTERY_API_ORIGIN).replace(/\/$/, "");
}
/**
* axios `baseURL`
* - 浏览器始终请求同源 `/api/v1`
* - 线上由宝塔转发 `/api/*` 到 Laravel
* - 本地开发由 `app/api/[...path]/route.ts` 临时代理到 `LOTTERY_API_UPSTREAM`
*/
export function resolveLotteryApiV1Base(): string {
return "/api/v1";
}