refactor(env, i18n, http): 更新环境配置与错误提示信息
修改 .env.example,简化 API 配置说明并明确生产环境要求。更新多语言错误提示,确保用户在未启用 API 代理时获得清晰反馈。重构 admin-http.ts,优化 API 基础 URL 的解析逻辑,提升代码可维护性。
This commit is contained in:
@@ -1,19 +1,4 @@
|
||||
/**
|
||||
* 管理端 API 连接方式:
|
||||
* - 默认:浏览器请求同源 `/api/*`,由 next.config `rewrites` 转发到 Laravel(需配置服务端 `API_BASE_URL`)。
|
||||
* - 可选:设置 `NEXT_PUBLIC_LOTTERY_API_BASE_URL` 直连后端(不经 Next 反代)。
|
||||
*/
|
||||
/** 是否已配置可请求的 Laravel API(默认有本地 origin,极少用 PROXY_DISABLED 关闭)。 */
|
||||
export function hasLotteryAdminApiBaseUrl(): boolean {
|
||||
const direct = process.env.NEXT_PUBLIC_LOTTERY_API_BASE_URL?.trim();
|
||||
if (direct !== undefined && direct !== "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return process.env.NEXT_PUBLIC_LOTTERY_API_PROXY_DISABLED !== "true";
|
||||
}
|
||||
|
||||
/** 直连模式下的 Laravel API 根(含 `/api` 前缀由调用方 path 决定) */
|
||||
export function lotteryAdminApiDirectOrigin(): string | null {
|
||||
const direct = process.env.NEXT_PUBLIC_LOTTERY_API_BASE_URL?.trim();
|
||||
return direct !== undefined && direct !== "" ? direct.replace(/\/$/, "") : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user