From 8e538fea80be5fd850f063a870230cf2f42388a9 Mon Sep 17 00:00:00 2001 From: lezi-fun <177434121+lezi-fun@users.noreply.github.com> Date: Tue, 11 Aug 2026 19:40:52 +0800 Subject: [PATCH] chore: allowedDevOrigins reads ALLOWED_DEV_ORIGINS env (no hardcoded IPs) Dev-only origin allowlist stays 127.0.0.1 by default; LAN devices can be enabled per-machine via ALLOWED_DEV_ORIGINS=ip1,ip2 without touching the repo. --- next.config.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index fd70d1d..cb9f5b8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,11 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - // 本地开发同时支持 localhost 和 127.0.0.1,避免客户端脚本被跨源保护拦截。 - allowedDevOrigins: ['127.0.0.1'], + // 本地开发允许的来源:默认本机;局域网/其他设备通过环境变量追加 + // ALLOWED_DEV_ORIGINS=192.168.x.x,10.0.0.x (仅开发用,不写死具体 IP) + allowedDevOrigins: [ + '127.0.0.1', + ...(process.env.ALLOWED_DEV_ORIGINS ? process.env.ALLOWED_DEV_ORIGINS.split(',').map((s) => s.trim()) : []), + ], // Docker 部署用 standalone 输出;serverless(Vercel/CF Pages)不需要 ...(process.env.DOCKER ? { output: 'standalone' } : {}), // /uploads/* 由 API 路由提供(上传文件运行时新增,不进 public 构建快照)