今使用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. Java所用相关软件的大致安装流程

    JAVA下载流程 一.相关环境的安装与配置 1.JDK的下载 去官网搜索相应的java版本,并进行下载 官网链接:www.xfdown.com/soft/125774.html在该链接下,可以下载ja ...

  2. Spring------bean基础配置

    Bean基础配置 Bean的别名配置: 在执勤已经定义好id的基础上,如果对该名称并不是很满意,但是又不是很想要去修改许多又利用到它的地方,可以选择在ApplicationContext.xml中配置 ...

  3. 红黑树(map与unorder_map)B B+树

    红黑树(map) 这个里面有插入的几种方式:红黑树性质的理解 先说性质,1 每个节点要么红要么黑,2 一个节点为红色,左右两个孩子都是黑, 3 根节点是黑, 4 每个叶子(nil)节点都是黑色, 5 ...

  4. C# 动态创建类,动态创建表,支持多库的数据库维护方案

    1.创建表 SqlSugar支持了3种模式的建表,非常的灵活,可以MYSQL MSSQL ORACLE等用同一语法创建数据库,不需要考虑数据库的兼容性 中间标准: string  大文本 5.1.3. ...

  5. 【深入浅出 Yarn 架构与实现】5-1 Yarn 资源调度器基本框架

    资源调度器是 YARN 中最核心的组件之一,它是 ResourceManager 中的一个插拔式服务组件,负责整个集群资源的管理和分配. Yarn 默认提供了三种可用资源调度器,分别是FIFO (Fi ...

  6. 新旧版本功能对比 | v1.5.0 全新升级

    Hi~社区的小伙伴们大家好呀! CloudQuery 最新 1.5.0 社区版本即将于 4月14日 发布,正式上线前,我们迫不及待与大家分享与 v1.4 相比,v1.5.0 在性能和功能上有哪些更新和 ...

  7. Hugging News #0407: Google AI 的 Pix2Struct 来啦、开发者资源页面发布

    每一周,我们的同事都会向社区的成员们发布一些关于 Hugging Face 相关的更新,包括我们的产品和平台更新.社区活动.学习资源和内容更新.开源库和模型更新等,我们将其称之为「Hugging Ne ...

  8. React redux toolkit: Uncaught Error:[Immer] An immer producer returned a new...

    React在写一个购物车的redux toolkit时遇到了问题.核心代码如下: import { createSlice } from "@reduxjs/toolkit"; c ...

  9. Rust中的智能指针:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak<T>

    Rust中的智能指针是什么 智能指针(smart pointers)是一类数据结构,是拥有数据所有权和额外功能的指针.是指针的进一步发展 指针(pointer)是一个包含内存地址的变量的通用概念.这个 ...

  10. [Pytorch框架] 3.1 logistic回归实战

    文章目录 3.1 logistic回归实战 3.1.1 logistic回归介绍 3.1.2 UCI German Credit 数据集 3.2 代码实战 import torch import to ...