Failed to load http://localhost:8080/team.php: Request header field x-jwt-header is not allowed by Access-Control-Allow-Headers in preflight response.
2018-02-07 09:31
986 查看
axios 加入header之后,请求出现
Failed to load http://localhost:8080/team.php: Request header field x-jwt-header is not allowed by Access-Control-Allow-Headers in preflight response.
原因是后端没有开启对header的允许。php中输入以下代码即可:
Failed to load http://localhost:8080/team.php: Request header field x-jwt-header is not allowed by Access-Control-Allow-Headers in preflight response.
//POST传参序列化(添加请求拦截器) axios.interceptors.request.use(config => { config.headers['x-jwt-header'] = localStorage.token return config; },error =>{ alert("错误的传参", 'fail') return Promise.reject(error) })
原因是后端没有开启对header的允许。php中输入以下代码即可:
header('Access-Control-Allow-Headers:x-jwt-header,content-type');
相关文章推荐
- 9.如何解决出现AXIOS的Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
- Request header field sessionId is not allowed by Access-Control-Allow-Headers in preflight response.
- Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight respon
- Request header field attachmentdata is not allowed by Access-Control-Allow-Headers in preflight resp
- response错误:Request header field Content-Type is not allowed by Access-Control-Allow-Headers in prefl
- Request header field Content-Type is not allowed by Access-Control-Allow-Headers跨域
- Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers
- vue-resource Content-Type is not allowed by Access-Control-Allow-Headers in preflight response
- Request header field Content-Type is not allowed by Access-Control-Allow-Headers
- Request header field Content-Type is not allowed by Access-Control-Allow-Headers跨域
- Error :Request header field Content-Type is not allowed by Access-Control-Allow-Headers post请求失败原因
- XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.
- 使用chrome调试ajax加载本地文件的时候出现Failed to load resource: Origin null is not allowed by Access-Control-Allow
- XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.
- XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.
- jquey XMLHttpRequest cannot load url.Origin null is not allowed by Access-Control-Allow-Origin
- XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.
- XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.
- Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
- XMLHttpRequest在请求失败(Origin null is not allowed by Access-Control-Allow-Origin.)