美文网首页
node设置允许跨域get、post请求

node设置允许跨域get、post请求

作者: 幸福幸福幸福 | 来源:发表于2017-07-14 15:53 被阅读166次
//设置跨域访问
app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With,Content-Type");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By",' 3.2.1')
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});

相关文章

网友评论

      本文标题:node设置允许跨域get、post请求

      本文链接:https://www.haomeiwen.com/subject/txqohxtx.html