diff --git a/server/index.js b/server/index.js index e75f8de..e8b0cf4 100644 --- a/server/index.js +++ b/server/index.js @@ -3,7 +3,7 @@ import express from 'express' import cors from 'cors' import grpc from '@grpc/grpc-js' import protoLoader from '@grpc/proto-loader' -import { resolve } from 'path'; +import path from 'path'; import { fileURLToPath } from 'url'; import 'dotenv/config'; @@ -247,18 +247,18 @@ const PORT = process.env.VITE_SERVICE_PORT || 3000; // ============ 生产环境:托管 Vite 构建产物 ============ if (isProd) { - const distPath = resolve(__dirname, '../dist'); + const distPath = path.resolve(__dirname, '../dist'); // 托管静态文件 app.use(express.static(distPath)); // SPA 回退:所有非 API 请求返回 index.html app.get('*', (req, res) => { - res.sendFile(resolve(distPath, 'index.html')); + res.sendFile(path.resolve(distPath, 'index.html')); }); app.post('*', (req, res) => { - res.sendFile(resolve(distPath, 'index.html')); + res.sendFile(path.resolve(distPath, 'index.html')); }); }