CORS problem resolve

This commit is contained in:
2026-01-03 18:16:18 +03:00
parent 85d1a9f046
commit 58b88c05a7

View File

@@ -20,6 +20,16 @@ const appPort = 3000;
const app = express();
app.use(express.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
if (req.method === 'OPTIONS') {
res.sendStatus(204);
return;
}
next();
});
const adapter = new DBAdapter({
dbHost: HOST,