Implement request handling for 3D models in app.js

- Added middleware to prevent direct access to /models/ paths, directing users to use /api/models/ instead for optimized 3D models.
- Updated comments to clarify the purpose of the new middleware and its role in serving models through the API.
This commit is contained in:
Torsten Schulz (local)
2026-01-22 13:40:03 +01:00
parent 4379b0b955
commit 7303d1ea0b

View File

@@ -80,7 +80,14 @@ app.use('/api/blog', blogRouter);
app.use('/api/termine', termineRouter);
// Serve frontend SPA for non-API routes to support history mode clean URLs
// /models/* nicht statisch ausliefern nur über /api/models (Proxy mit Komprimierung)
const frontendDir = path.join(__dirname, '../frontend');
app.use((req, res, next) => {
if (req.path.startsWith('/models/')) {
return res.status(404).send('Use /api/models/ for 3D models (optimized).');
}
next();
});
app.use(express.static(path.join(frontendDir, 'dist')));
app.get(/^\/(?!api\/).*/, (req, res) => {
res.sendFile(path.join(frontendDir, 'dist', 'index.html'));