34 lines
1005 B
Plaintext
34 lines
1005 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 already handles ALL HTML requests
|
||
|
|
// Static files only serve: CSS, JS, images, fonts - NOT HTML
|
||
|
|
app.use(express.static(__dirname, {
|
||
|
|
index: false,
|
||
|
|
// Don't serve HTML files - middleware handles them
|
||
|
|
extensions: ['html'] // This tells express.static to NOT serve .html files
|
||
|
|
}));
|
||
|
|
app.use('/home', express.static(__dirname, {
|
||
|
|
index: false,
|
||
|
|
extensions: ['html']
|
||
|
|
}));
|
||
|
|
|
||
|
|
app.listen(PORT, () => {
|
||
|
|
console.log(`Server running on port ${PORT}`);
|
||
|
|
console.log('Dynamic SEO enabled!');
|
||
|
|
});
|
||
|
|
|
||
|
|
export default app;
|