Failed to load http://localhost:8080/team.php: Request header field x-jwt-header is not allowed by A

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'); 
相關文章
相關標籤/搜索