用的nestjs nest的内部用的是express
如果直接在header中设置
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'OPTIONS,GET,POST,PUT,DELETE');
res.header("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept,Authorization");
res.header("cache-control", "no-cache");
res.header("content-type", "application/json; charset=utf-8");
res.header("ETag", '');
if ('OPTIONS' === req.method) {
res.send(204);
}
else {
next();
}
});
但是浏览器只请求一次(204)就不再请求### 问题描述