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:
2026-05-29 10:28:43 +08:00
parent 1316a62ce3
commit 03faed1db6
19 changed files with 71 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
import { NextResponse, type NextRequest } from "next/server";
import { LOTTERY_API_V1_BASE } from "./src/api/paths";
import { generateCSP, nonCspSecurityHeaders } from "./src/lib/csp-config";
type RuntimeOriginsEnvelope = {
@@ -11,7 +12,7 @@ type RuntimeOriginsEnvelope = {
async function loadRuntimeOrigins(request: NextRequest): Promise<string[]> {
try {
const url = new URL("/api/v1/integration/runtime-origins", request.url);
const url = new URL(`${LOTTERY_API_V1_BASE}/integration/runtime-origins`, request.url);
const response = await fetch(url, {
headers: { Accept: "application/json" },
cache: "no-store",