express 配置前端跨域访问

app.use(function(req,res,next){
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type');
res.header("Content-Type", "application/json;charset=utf-8");
res.header('Access-Control-Allow-Credentials','true');
next();
})
posted @ 2019-07-29 10:42  Pikaqu  阅读(269)  评论(0编辑  收藏  举报