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; // Configure MIME types for JSX files app.use((req, res, next) => { if (req.path.endsWith('.jsx')) { res.setHeader('Content-Type', 'application/javascript'); } next(); }); // Serve static assets FIRST (CSS, JS, images, fonts) - these MUST work app.use('/assets', express.static(path.join(__dirname, '../dist/assets'))); app.use('/src', express.static(path.join(__dirname, '../src'))); app.use('/og', express.static(path.join(__dirname, '../dist/og'))); app.use(express.static(path.join(__dirname, '../dist'), { index: false, // Don't serve index.html automatically setHeaders: (res, filePath) => { // Only block HTML files - let everything else through if (filePath.endsWith('.html')) { res.status(404).end(); return; } } })); // CRITICAL: Apply SEO middleware AFTER static files // This ensures HTML requests go through SEO middleware // But static assets are served first app.use(seoMiddleware); app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); console.log('Dynamic SEO enabled!'); }); export default app;