diff --git a/server/index.js b/server/index.js index cb599e8..376f0c5 100644 --- a/server/index.js +++ b/server/index.js @@ -14,16 +14,6 @@ const PORT = process.env.PORT || 3001; app.use(cors()); app.use(express.json()); -// Set correct MIME types for static files -app.use((req, res, next) => { - if (req.url.endsWith('.js')) { - res.setHeader('Content-Type', 'application/javascript'); - } else if (req.url.endsWith('.css')) { - res.setHeader('Content-Type', 'text/css'); - } - next(); -}); - // API Routes // Get all groups @@ -383,8 +373,28 @@ app.post('/api/test-webhook', async (req, res) => { } }); -// Serve React app -app.use(express.static(path.join(__dirname, '../client/build'))); +// Serve React app with proper MIME types +const mimeTypes = { + '.js': 'application/javascript', + '.css': 'text/css', + '.json': 'application/json', + '.png': 'image/png', + '.jpg': 'image/jpeg', + '.gif': 'image/gif', + '.svg': 'image/svg+xml', + '.woff': 'font/woff', + '.woff2': 'font/woff2' +}; + +app.use(express.static(path.join(__dirname, '../client/build'), { + setHeaders: (res, filePath) => { + const ext = path.extname(filePath).toLowerCase(); + if (mimeTypes[ext]) { + res.setHeader('Content-Type', mimeTypes[ext]); + } + } +})); + app.get('*', (req, res) => { res.sendFile(path.join(__dirname, '../client/build/index.html')); });