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

This commit is contained in:
2026-06-08 00:05:06 +02:00
parent c7c6bed56c
commit afd29c0a23
2 changed files with 15 additions and 1 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) || '';

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 : {},