27 lines
803 B
JavaScript
27 lines
803 B
JavaScript
import express from 'express';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import seoMiddleware from './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 (CSS, JS, images)
|
|
app.use(express.static(path.join(__dirname, '../dist')));
|
|
// Also mount under /home because Vite base is /home/
|
|
app.use('/home', express.static(path.join(__dirname, '../dist')));
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Server running on port ${PORT}`);
|
|
console.log('Dynamic SEO enabled!');
|
|
});
|
|
|
|
export default app;
|