Upload app.js
Browse files- backend/src/app.js +14 -3
backend/src/app.js
CHANGED
@@ -45,14 +45,25 @@ app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
|
45 |
// 提供前端静态文件
|
46 |
app.use(express.static(path.join(__dirname, '../../frontend/dist')));
|
47 |
|
|
|
|
|
|
|
48 |
// API路由
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
app.use('/api/auth', authRoutes);
|
50 |
app.use('/api/ppt', authenticateToken, pptRoutes);
|
51 |
app.use('/api/public', publicRoutes);
|
52 |
|
53 |
-
//
|
54 |
-
app.
|
55 |
-
|
|
|
56 |
});
|
57 |
|
58 |
// 前端路由处理 - 必须在API路由之后
|
|
|
45 |
// 提供前端静态文件
|
46 |
app.use(express.static(path.join(__dirname, '../../frontend/dist')));
|
47 |
|
48 |
+
// 提供数据文件
|
49 |
+
app.use('/data', express.static(path.join(__dirname, '../../frontend/public/mocks')));
|
50 |
+
|
51 |
// API路由
|
52 |
+
console.log('Registering API routes...');
|
53 |
+
|
54 |
+
// 健康检查 - 需要在其他路由之前
|
55 |
+
app.get('/api/health', (req, res) => {
|
56 |
+
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
57 |
+
});
|
58 |
+
|
59 |
app.use('/api/auth', authRoutes);
|
60 |
app.use('/api/ppt', authenticateToken, pptRoutes);
|
61 |
app.use('/api/public', publicRoutes);
|
62 |
|
63 |
+
// 添加调试中间件 - 处理未匹配的API路由
|
64 |
+
app.use('/api/*', (req, res) => {
|
65 |
+
console.log(`Unmatched API route: ${req.method} ${req.path}`);
|
66 |
+
res.status(404).json({ error: 'API route not found', path: req.path });
|
67 |
});
|
68 |
|
69 |
// 前端路由处理 - 必须在API路由之后
|