19eba1eebd
Set up the HTTP server with Express, attach Socket.IO for real-time messaging, add CORS middleware, async error handling utility, and REST routes for room join/leave/messages/participants. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 lines
422 B
JavaScript
16 lines
422 B
JavaScript
function createCorsMiddleware(clientOrigin) {
|
|
return (req, res, next) => {
|
|
res.setHeader('Access-Control-Allow-Origin', clientOrigin)
|
|
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PATCH,DELETE,OPTIONS')
|
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
|
|
|
|
if (req.method === 'OPTIONS') {
|
|
return res.sendStatus(204)
|
|
}
|
|
|
|
next()
|
|
}
|
|
}
|
|
|
|
module.exports = createCorsMiddleware
|