Request header field userRole is not allowed by Access-Control-Allow-Headers in preflight response.
今使用axios 请求数据过程中遇到同事设置的请求头,在我请求的接口中部不被允许,于是老是提示Request header field userRole is not allowed by Access-Control-Allow-Headers in preflight response.异常
最后使用transformRequest 干掉不需要的headers
axios.get('https://www.baidu.com',{
transformRequest :[
(data, headers) => {
delete headers['userRole'];
return data;
}
]
}).then(res => {
console.log(res)
this.realData = res.data.data;
}).catch(err=>{
console.log(err)
})
在当前操作中移除掉我不需要的header,这样即获取了数据又不会影响到其他同事的操作一举两得,简单记录哈。
Request header field userRole is not allowed by Access-Control-Allow-Headers in preflight response.的更多相关文章
- post请求(headers里有属性)报错:Request header field xxx is not allowed by Access-Control-Allow-Headers in preflight response
post 请求,headers里有属性(xxx).请求时报错: XMLHttpRequest cannot load <url>. Request header field xxx is ...
- Request header field Content-Type is not allowed by Access-Control-Allow-Headers
今天遇到一个跨域问题记录学习下: 一.问题: 跨域请求中包含自定义header字段时,浏览器console报错. Request header field xfilesize is not allow ...
- 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.
axios 加入header之后,请求出现 Failed to load http://localhost:8080/team.php: Request header field x-jwt-head ...
- 浏览器报错问题解决:Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight respons
FAQ: Failed to load http://www.erpshop.com/index.php: Request header field Content-Type is not allow ...
- axios跨域请求报错:Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
在做项目时,用到axios,数据用post提交时,老是报错,错误提示为: Access to XMLHttpRequest at 'http://127.0.0.1:3000/api/add' fro ...
- 9.如何解决出现AXIOS的Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
问题描述: 由于restful接口需要在头部header传递两个字段: Content-Type: application/jsonAccess-Token: 84c6635800b14e0eba4f ...
- 如何解决出现AXIOS的跨域问题:Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
转载:https://www.cnblogs.com/caimuqing/p/6733405.html 问题描述: 由于restful接口需要在头部header传递两个字段: Content-Type ...
- has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
https://www.cnblogs.com/caimuqing/p/6733405.html // TODO 支持跨域访问 response.setHeader("Access-Cont ...
- Request header field * is not allowed by Access-Control-Allow-Headers in preflight response问题解决
跨域问题报错信息为:Failed to load http://192.168.30.119: Request header field language is not allowed by Acce ...
- 解决Bug:Size of a request header field exceeds server limit
用了cms 发现这玩意真不好,老是有各种奇芭的问题跳出来 有时浏览网页时会出现 Bad Request Your browser sent a request that this server cou ...
随机推荐
- MybatisX无法自动生成entity实体类
在做项目的时候,安装MybatisX插件可以让我们不用写实体类,加快我们的开发速度,让我们更专注于业务逻辑的开发,可是最近在做项目的时候,发现MybatisX插件的MybatisX-Generator ...
- 基于Sekiro的jsRPC的使用和安装
什么是jsRPC 说实话在介绍 JSRPC 我向大家推荐一个库 Selenium-wire 感觉和JSrpc的原理很像 RPC指远程过程调用,APP里面的RPC大家比较熟悉了. 那什么是jsRPC,顾 ...
- 使用go的并发性来解决Hilbert酒店问题
译自:Designing for Concurrency: the Hilbert's Hotel Problem in Go,本文使用go的并发性来解决Hilbert酒店问题.本文比较有意思的是它对 ...
- 使用requests发送post请求登录
post请求 语法结构 requests.post(url,data=None,json=None) 参数说明 url:需要爬取的网址 data:请求数据 json:json格式的数据 案例:登录小说 ...
- 推荐三款 Mac 上的理财神器 iCompta、Rublik、UctoX
今天推荐三款理财神器,像个人的话可以使用 iCompta(个人财务管理)一款软件就好了,但有些朋友可能有关注汇率的需求,可以使用 Rublik(汇率动态),还有一些小伙伴可能有自己的公司等原因财务量较 ...
- react中登录注册 使用验证码验证
后端接口 var express = require('express'); var router = express.Router(); var User = require('./../sql/c ...
- selenium验证码处理-获取验证码图片二进流数据转成原图保存
1.因为视频的作者给的代码不完整,只有核心部分的代码. 2.视频作者示例使用的第三方破解12306的脚本网页(失效了) 所以本人无法复现,此次截取部分代码作为理解核心意思(思想方法最重要) 1.面向对 ...
- 势如破竹的雷霆两招,微服务进阶Serverless
在应用开发中,服务器的开发一直是最重要的部分之一.在服务器开发不断演进过程中,我们可以将它简单分为5个阶段: 物理机阶段->虚拟机阶段->云计算阶段->容器阶段->当前的Se ...
- 随机服务系统模拟—R实现(二)
M/M/1随机服务系统的模拟 M/M/1模型是一种出生-死亡过程,此随机过程中的每一个状态代表模型中人数的数目.因为模型的队列长度无限且参与人数亦无限,故此状态数目亦为无限.例如状态0表示模型闲置.状 ...
- [Git/SVN] Gitee使用教程
1 Gitee Gitee 提供免费的 Git 仓库,还集成了代码质量检测.项目演示等功能. 对于团队协作开发,Gitee 还提供了项目管理.代码托管.文档管理的服务,5 人以下小团队免费. CASE ...