express跨域问题

自己创建了一个express项目,连接了远端mysql,写了接口,使用浏览器地址访问能成功并取到数据。

使用vue全家桶构建了前端项目,axios处理请求,跨域。

Request header field timestamp is not allowed by Access-Control-Allow-Headers in preflight response.

添加了以下代码,仍然没有效果:

res.header("Content-Type", "text/plain");
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

是不是我axios请求header需要设置什么?

阅读 6.6k
2 个回答
Request header field timestamp is not allowed by Access-Control-Allow-Headers in preflight response.
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, timestamp ");
推荐问题