鍍金池/ 問答/人工智能  HTML/ express跨域問題

express跨域問題

自己創(chuàng)建了一個express項目,連接了遠端mysql,寫了接口,使用瀏覽器地址訪問能成功并取到數(shù)據。

使用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需要設置什么?

回答
編輯回答
孤酒
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 ");
2017年11月8日 14:44
編輯回答
夏木
2018年4月27日 08:06