expanding CORS options and enabling explicit preflight response
This commit is contained in:
parent
3044ad6783
commit
2a7b525b83
@ -41,7 +41,16 @@ app.use(cors({
|
||||
credentials: true
|
||||
}));
|
||||
app.use((req, res, next) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*');
|
||||
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||
res.setHeader('Access-Control-Allow-Private-Network', 'true');
|
||||
|
||||
if (req.method === 'OPTIONS') {
|
||||
return res.status(200).end();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
app.use(express.json());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user