Compare commits
2 Commits
presejpack
...
presejpack
| Author | SHA1 | Date | |
|---|---|---|---|
| 16b0568bf1 | |||
| afd29c0a23 |
@@ -9,6 +9,13 @@ const __dirname = path.dirname(__filename);
|
||||
const app = express();
|
||||
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
|
||||
app.use((req, res, next) => {
|
||||
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();
|
||||
});
|
||||
|
||||
// Serve static files from the 'dist' directory
|
||||
app.use(express.static(path.join(__dirname, 'dist')));
|
||||
// Serve static files from the 'dist' directory, but bypass index.html requests
|
||||
// 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
|
||||
app.get('*', (req, res) => {
|
||||
|
||||
@@ -12,8 +12,15 @@ export default defineConfig(() => {
|
||||
},
|
||||
},
|
||||
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.
|
||||
// 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',
|
||||
// Disable file watching when DISABLE_HMR is true to save CPU during agent edits.
|
||||
watch: process.env.DISABLE_HMR === 'true' ? null : {},
|
||||
|
||||
Reference in New Issue
Block a user