版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhuoganliwanjin/article/details/88061599
从来没遇到过这个问题,并且估计自己以后还会遇到这个问题,所以发文章记录一下。
报错的原因是前后端的请求头没有对应上,解决方法
app.all('*',function(req, res, next) {//处理跨域
res.header("Access-Control-Allow-Origin","*");
res.header("Access-Control-Allow-Headers","X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1');
//res.header("Content-Type","*"); /**/
next();
})
后端不在设置数据类型,意思就是前端你随意发,我什么都接着。