app.all(’*’, function(req, res, next) {
res.header(“Access-Control-Allow-Credentials”, “true”);
res.header(“Access-Control-Allow-Origin”, req.headers.origin);
res.header(“Access-Control-Allow-Methods”, “PUT,GET,POST,DELETE,OPTIONS”);
res.header(“Access-Control-Allow-Headers”, “Content-Type,username”);
if(req.method == ‘OPTIONS’) {
res.sendStatus(200);
} else {
next();
}
});
nodejs跨域socket.io 请求头设置
最新推荐文章于 2024-07-29 10:13:36 发布