feat: 更新 API 路径配置并优化环境变量管理
- 修改 .env.example,更新玩家端本地配置说明,新增直连 Laravel 和局域网 IP 访问配置项,提升开发灵活性。 - 更新 middleware.ts,使用新的 LOTTERY_API_V1_BASE 常量构建 API 请求路径,简化代码结构。 - 在 next.config.ts 中引入 parseAllowedDevOrigins 函数,动态解析允许的开发来源,增强安全性。 - 重构多个 API 模块,移除 API_V1_PREFIX,直接使用相对路径,简化 API 调用逻辑,提高可维护性。
This commit is contained in:
@@ -13,13 +13,13 @@ import {
|
||||
} from "@/types/api/errors";
|
||||
import { isApiEnvelope } from "@/types/api/envelope";
|
||||
import { useErrorStore } from "@/stores/error-store";
|
||||
import { LOTTERY_API_V1_BASE } from "@/api/paths";
|
||||
|
||||
/**
|
||||
* **第一层**:只挂 `baseURL` / `timeout` / 默认 `Accept`。业务解析、toast 都不在这里。
|
||||
* **第一层**:`baseURL` 对齐 Laravel `api/v1`;各 `api/*.ts` 只写业务 path(如 `/currencies`)。
|
||||
*/
|
||||
export const lotteryHttp = axios.create({
|
||||
// 统一走 Next 同源 /api 代理,由 next.config.ts 的 API_BASE_URL 转发到后端。
|
||||
baseURL: "/api",
|
||||
baseURL: LOTTERY_API_V1_BASE,
|
||||
timeout: 30_000,
|
||||
headers: { Accept: "application/json" },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user