今使用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.的更多相关文章

  1. 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 ...

  2. Request header field Content-Type is not allowed by Access-Control-Allow-Headers

    今天遇到一个跨域问题记录学习下: 一.问题: 跨域请求中包含自定义header字段时,浏览器console报错. Request header field xfilesize is not allow ...

  3. 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 ...

  4. 浏览器报错问题解决: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 ...

  5. 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 ...

  6. 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 ...

  7. 如何解决出现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 ...

  8. 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 ...

  9. 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 ...

  10. 解决Bug:Size of a request header field exceeds server limit

    用了cms 发现这玩意真不好,老是有各种奇芭的问题跳出来 有时浏览网页时会出现 Bad Request Your browser sent a request that this server cou ...

随机推荐

  1. 在jsp页面int和String类型的相互转换

    浅浅地来做一个对比吧! .java文件 int转成string类型:String s=String.valueOf(int m); String转成int类型:int m=Integer.parseI ...

  2. Markdown合并单元格

    参考博客:https://blog.csdn.net/qq_32042527/article/details/88084130

  3. 关于lambda的由来

    总结lambda表达式的本质就是匿名方法,根据委托推断类型 class Program { static void Main(string[] args) { //泛型委托 最后一个是返回值 Acti ...

  4. SpringBoot 启动类的原理

    SpringBoot启动类上使用 @SpringBootApplication注解,该注解是一个组合注解,包含多个其它注解.和类定义(SpringApplication.run)要揭开 SpringB ...

  5. QML 界面切换的几种方法(带示例代码)

    QML 界面切换的几种方法(带示例代码)

  6. Flask快速入门day02(1、CBV使用及源码分析,2、模板用法,3、请求与响应的基本用法,4、session的使用及源码分析,5、闪现,6、请求扩展)

    目录 Flask框架 一.CBV分析 1.CBV编写视图类方法 二.CBV源码分析 1.CBV源码问题 2.补充问题 3.总结 三.模板 1.py文件 2.html页面 四.请求与响应 1.reque ...

  7. blender资源库 【自用】

    1 https://www.threedscans.com A Website with a lot of photo-scanned sculptures which are free to use ...

  8. 1.springsecurity基于内存和数据库的认证

    1.总结: 昨天主要是使用security实现了基于内存的认证和基于数据库的认证(实际项目中使用): 在security的项目中,必须配置WebSecurityConfigurerAdaptor的实现 ...

  9. ServletContext 详解(转载)

    转载:https://www.cnblogs.com/zjdxr-up/p/7761813.html ServletContext,是一个全局的储存信息的空间,服务器开始,其就存在,服务器关闭,其才释 ...

  10. Idea快捷键——Extract Method

    idea快捷键 ctrl+alt+M 作用:将一段代码提取为一个方法