refactor(env, api, i18n): 更新环境配置与API代理逻辑
修改 .env.example,优化API配置说明并明确线上环境要求。更新多语言错误提示,确保用户在未启用API代理时获得清晰反馈。重构API代理逻辑,移除开发代理文件,简化代码结构,提升可维护性。
This commit is contained in:
49
ecosystem.config.cjs
Normal file
49
ecosystem.config.cjs
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 管理端(lotteryadmin)宝塔 PM2 配置
|
||||
*
|
||||
* 部署步骤(在服务器项目目录执行):
|
||||
* 1. 复制 .env.example 为 .env,按线上域名填写
|
||||
* 2. npm ci && npm run build
|
||||
* 3. 修改下方 cwd 为服务器上的实际路径(默认即本文件所在目录)
|
||||
* 4. pm2 start ecosystem.config.cjs
|
||||
* 5. pm2 save && pm2 startup
|
||||
*
|
||||
* 宝塔:PM2 管理器 → 添加项目 → 选择本文件。
|
||||
* Nginx:反代到 127.0.0.1:3801 即可;/api 由 Next 转发到 LOTTERY_API_UPSTREAM,无需单独配。
|
||||
*/
|
||||
|
||||
const path = require("path");
|
||||
|
||||
/** 改成服务器上的绝对路径,例如 /www/wwwroot/lotteryadmin.tanumo.com */
|
||||
const APP_CWD = path.resolve(__dirname);
|
||||
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: "lotteryadmin",
|
||||
cwd: APP_CWD,
|
||||
script: "node_modules/next/dist/bin/next",
|
||||
args: "start -p 3801 -H 127.0.0.1",
|
||||
interpreter: "node",
|
||||
exec_mode: "fork",
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: "1G",
|
||||
time: true,
|
||||
merge_logs: true,
|
||||
out_file: path.join(APP_CWD, "logs/pm2-out.log"),
|
||||
error_file: path.join(APP_CWD, "logs/pm2-error.log"),
|
||||
|
||||
env: {
|
||||
NODE_ENV: "production",
|
||||
PORT: "3801",
|
||||
|
||||
// Laravel 根地址(无尾部 /);同机部署填 http://127.0.0.1:8000
|
||||
LOTTERY_API_UPSTREAM: "http://127.0.0.1:8000",
|
||||
},
|
||||
|
||||
// env_file: path.join(APP_CWD, ".env"),
|
||||
},
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user