From 6c295ba80bb1e968448b91bcbaf5eda9d7a591c6 Mon Sep 17 00:00:00 2001 From: patdelphi Date: Tue, 19 Aug 2025 19:17:44 +0800 Subject: [PATCH] Fix production environment detection for Koyeb deployment - Add fallback detection using PORT=8000 for Koyeb - Add environment debugging logs - Ensure static file serving is enabled in production - Fix NODE_ENV detection issues in containerized deployment --- server/index.cjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/index.cjs b/server/index.cjs index dab5bbb..ae1d403 100644 --- a/server/index.cjs +++ b/server/index.cjs @@ -94,7 +94,13 @@ app.use('/api/history', historyRoutes); app.use('/api/profile', profileRoutes); // 静态文件服务 (用于生产环境) -if (process.env.NODE_ENV === 'production') { +// 强制在 Koyeb 部署时启用静态文件服务 +const isProduction = process.env.NODE_ENV === 'production' || process.env.PORT === '8000'; +console.log('当前环境:', process.env.NODE_ENV); +console.log('端口:', process.env.PORT); +console.log('是否为生产环境:', isProduction); + +if (isProduction) { const distPath = path.join(__dirname, '../dist'); const indexPath = path.join(distPath, 'index.html');