fix: 修复生产环境 CORS 错误 - SSR 使用 API_URL 而非 NEXT_PUBLIC_API_URL
- 将登录页 SSR 获取组织列表改为读取 API_URL 环境变量 - 避免 NEXT_PUBLIC_* 变量泄露到客户端导致跨域请求 localhost - 客户端 api.ts 已使用空字符串(same-origin 通过 nginx 代理)
This commit is contained in:
@@ -7,7 +7,8 @@ import LoginForm from "./login-form";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
async function getOrganizations(): Promise<Organization[]> {
|
||||
const base = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8080";
|
||||
// 服务端 SSR 用内网地址,不使用 NEXT_PUBLIC_* 避免泄露到客户端
|
||||
const base = process.env.API_URL || "http://localhost:8080";
|
||||
try {
|
||||
const res = await fetch(`${base}/api/v1/organizations`, {
|
||||
cache: "no-store",
|
||||
|
||||
Reference in New Issue
Block a user