axios 加入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.ios
//POST传参序列化(添加请求拦截器)
axios.interceptors.request.use(config => {
config.headers['x-jwt-header'] = localStorage.token return config; },error =>{ alert("错误的传参", 'fail') return Promise.reject(error) })
缘由是后端没有开启对header的容许。php中输入如下代码便可:axios
header('Access-Control-Allow-Headers:x-jwt-header,content-type');