feat:环境变量处理

This commit is contained in:
MatrixSeven
2025-08-01 19:38:59 +08:00
parent 664fe2fdaa
commit dbfdbf0116
15 changed files with 396 additions and 1035 deletions

40
chuan-next/next.config.js Normal file
View File

@@ -0,0 +1,40 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
// 环境变量配置
env: {
GO_BACKEND_URL: process.env.GO_BACKEND_URL,
},
// 公共运行时配置
publicRuntimeConfig: {
apiBaseUrl: process.env.NEXT_PUBLIC_API_BASE_URL,
wsUrl: process.env.NEXT_PUBLIC_WS_URL,
},
// 服务器端运行时配置
serverRuntimeConfig: {
goBackendUrl: process.env.GO_BACKEND_URL,
},
// 重写规则 - 可选用于代理API请求
async rewrites() {
return [
{
source: '/api/proxy/:path*',
destination: `${process.env.GO_BACKEND_URL}/api/:path*`,
},
]
},
// 输出配置
output: 'standalone',
// 实验性功能
experimental: {
serverActions: {
allowedOrigins: ['localhost:3000', 'localhost:8080'],
},
},
}
module.exports = nextConfig