2 Commits

Author SHA1 Message Date
16b0568bf1 fix: bypass static index.html serving to allow dynamic header path rewriting
All checks were successful
Build and Push Presejpacky Docker Image / build-and-push (push) Successful in 6s
2026-06-08 00:08:25 +02:00
afd29c0a23 feat: add request header logging to dev and prod servers
All checks were successful
Build and Push Presejpacky Docker Image / build-and-push (push) Successful in 7s
2026-06-08 00:05:06 +02:00
2 changed files with 24 additions and 3 deletions

View File

@@ -9,6 +9,13 @@ const __dirname = path.dirname(__filename);
const app = express(); const app = express();
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
// Log all incoming request methods, URLs, and headers
app.use((req, res, next) => {
console.log(`[Express Request] ${req.method} ${req.url}`);
console.log('Headers:', JSON.stringify(req.headers, null, 2));
next();
});
// Middleware to strip base path prefix from request headers if present // Middleware to strip base path prefix from request headers if present
app.use((req, res, next) => { app.use((req, res, next) => {
const prefix = (req.headers['x-forwarded-prefix'] as string) || (req.headers['x-base-path'] as string) || ''; const prefix = (req.headers['x-forwarded-prefix'] as string) || (req.headers['x-base-path'] as string) || '';
@@ -23,8 +30,15 @@ app.use((req, res, next) => {
next(); next();
}); });
// Serve static files from the 'dist' directory // Serve static files from the 'dist' directory, but bypass index.html requests
app.use(express.static(path.join(__dirname, 'dist'))); // so they can be handled dynamically by our fallback route.
app.use((req, res, next) => {
if (req.url === '/index.html') {
return next();
}
next();
});
app.use(express.static(path.join(__dirname, 'dist'), { index: false }));
// Fallback to index.html for Single Page Application routing, injecting base path from headers // Fallback to index.html for Single Page Application routing, injecting base path from headers
app.get('*', (req, res) => { app.get('*', (req, res) => {

View File

@@ -12,8 +12,15 @@ export default defineConfig(() => {
}, },
}, },
server: { server: {
configureServer(server) {
server.middlewares.use((req, res, next) => {
console.log(`[Vite Request] ${req.method} ${req.url}`);
console.log('Headers:', JSON.stringify(req.headers, null, 2));
next();
});
},
// HMR is disabled in AI Studio via DISABLE_HMR env var. // HMR is disabled in AI Studio via DISABLE_HMR env var.
// Do not modify—file watching is disabled to prevent flickering during agent edits. // Do not modify—file watching is disabled to prevent flickering during agent edits.
hmr: process.env.DISABLE_HMR !== 'true', hmr: process.env.DISABLE_HMR !== 'true',
// Disable file watching when DISABLE_HMR is true to save CPU during agent edits. // Disable file watching when DISABLE_HMR is true to save CPU during agent edits.
watch: process.env.DISABLE_HMR === 'true' ? null : {}, watch: process.env.DISABLE_HMR === 'true' ? null : {},