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.5k
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 ");
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题