feat: add CORS support and enhance session routes for better sensor management

This commit is contained in:
Giuseppe Raffa
2026-04-14 19:39:26 +02:00
parent 137c6131c3
commit bf66845528
4 changed files with 121 additions and 12 deletions

View File

@@ -8,6 +8,15 @@ const wsHandler = require('./ws/handler');
app.use(express.json());
// CORS — consenti richieste dalla console e altri client browser
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type');
if (req.method === 'OPTIONS') return res.sendStatus(204);
next();
});
// DATABASE POSTGRESQL
app.get('/', (req, res) => {