axios跨域请求报错

在nodejs的入口js中的配置路由之前加入这一段就可以了

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");
    next();
});

 

posted @ 2018-08-10 15:27  第一神坑  Views(1732)  Comments(0Edit  收藏  举报