PozoAppUptoWebinar/dist1 (2)/server.js.backup

27 lines
843 B
Plaintext

import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import seoMiddleware from './server/seo-middleware.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
const PORT = process.env.PORT || 3000;
// CRITICAL: Apply SEO middleware FIRST (before static files)
// This ensures HTML requests go through SEO middleware
app.use(seoMiddleware);
// Serve static files - BUT middleware handles all HTML requests
// Static middleware will only serve non-HTML files (CSS, JS, images)
app.use(express.static(__dirname, { index: false }));
app.use('/home', express.static(__dirname, { index: false }));
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
console.log('Dynamic SEO enabled!');
});
export default app;