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

express跨域問題

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

使用vue全家桶構(gòu)建了前端項(xiàng)目,axios處理請(qǐng)求,跨域。

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請(qǐng)求header需要設(shè)置什么?

回答
編輯回答
孤酒
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