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();
});
原文地址:https://www.cnblogs.com/lskzj/p/9455249.html