Axios未在请求中放置原始标头
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Axios未在请求中放置原始标头相关的知识,希望对你有一定的参考价值。
我在反应中使用axios,他没有将Origin标头放在请求中,所以他给了服务器端cors(nodejs)问题。
import axios from 'axios';
const api = axios.create({baseURL: window.location.protocol + '//' + window.location.hostname + '/node/api/', withCredentials: true});
export default api;
答案
您需要将配置参数放入curl。
import axios from 'axios';
axios.defaults.withCredentials = true;
const api = axios.create({baseURL: window.location.protocol + '//' + window.location.hostname + '/node/api/'});
export default api;
以上是关于Axios未在请求中放置原始标头的主要内容,如果未能解决你的问题,请参考以下文章