fix 502
This commit is contained in:
@@ -34,4 +34,4 @@ EXPOSE 3000
|
|||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
CMD curl -f http://localhost:3000 || exit 1
|
CMD curl -f http://localhost:3000 || exit 1
|
||||||
# 启动命令
|
# 启动命令
|
||||||
CMD ["npm", "run", "start"]
|
CMD ["node", "server.cjs"]
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "Pandora 前端应用",
|
"description": "Pandora 前端应用",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite preview --host 0.0.0.0 --port 3000",
|
"start": "node server.cjs",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
@@ -26,7 +26,9 @@
|
|||||||
"vee-validate": "^4.10.5",
|
"vee-validate": "^4.10.5",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-router": "^4.2.4",
|
"vue-router": "^4.2.4",
|
||||||
"vue-toastification": "^2.0.0-rc.5"
|
"vue-toastification": "^2.0.0-rc.5",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"http-proxy-middleware": "^2.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.6.3",
|
"@types/node": "^20.6.3",
|
||||||
|
|||||||
25
frontend/server.cjs
Normal file
25
frontend/server.cjs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
// API 代理
|
||||||
|
app.use('/api', createProxyMiddleware({
|
||||||
|
target: 'http://backend:3001',
|
||||||
|
changeOrigin: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 静态文件服务
|
||||||
|
const staticPath = path.join(__dirname, 'dist');
|
||||||
|
app.use(express.static(staticPath));
|
||||||
|
|
||||||
|
// 处理所有其他路由,返回 index.html
|
||||||
|
app.get('*', (req, res) => {
|
||||||
|
res.sendFile(path.join(staticPath, 'index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
|
const port = process.env.PORT || 3000;
|
||||||
|
app.listen(port, '0.0.0.0', () => {
|
||||||
|
console.log(`Server is running on port ${port}`);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user