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.
2023-09-11 14:16:39 时间
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.
//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');
相关文章
- pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”
- Can't find PHP headers in /usr/include/php
- PHP引用(&)使用详解
- 一道无限极类 PHP 试题
- PHP全栈学习笔记16
- PHP json_decode 函数解析 json 结果为 NULL 的解决方法
- 《PHP、MySQL和Apache入门经典(第5版)》一一第1章 安装QuickStart向导
- Apache 的 php.ini 配置文件详解
- WDCP3.3中多PHP版本安装方法,以及安装遇到的问题
- php实现登录失败次数限制
- PySe-016-Requests 访问 HTTPS 网站报错解决方法:SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
- php base64不能解码_PHP base64编码后解码乱码的解决办法
- PHP百分号转小数,php 小数转换百分数函数
- php.ini中safe_mode开启之后对于PHP系统函数的影响
- PHP的mod_rewrite重写模块将.php后缀换成.html
- php抓取网页
- Using FastCGI to Host PHP Applications on IIS 7 -IIS7 怎么配置 PHP5
- PHP PHPStorm 解决运行报错 502 Bad Gateway,配置PHP Interpreter,配置php.exe
- 一个CMS案例实战讲解PHP代码审计入门