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 ...
随机推荐
- Jquery 和 Vue 入门学习
0x01 前言 零零散散学完了html.css.javascript的基础知识,但感觉写不了什么炫酷的前端界面,始终对前端开发有种生疏感.而时间的流逝也总会让我忘却零碎学习到的知识!为了改变这种尴 ...
- Flink 编程接口(Flink SQL Table API DataStream API 和 DataSet API Stateful Stream Process API)
Flink 根据数据集类型的不同将核心数据处理接口分为两大类,一类是支持批计算的接口DataSet API,另外一类是支持流计算的接口 DataStream API.同时 Flink将数据处理接口抽象 ...
- 全网最详细中英文ChatGPT-GPT-4示例文档-从0到1快速入门python代码解释应用——官网推荐的48种最佳应用场景(附python/node.js/curl命令源代码,小白也能学)
目录 Introduce 简介 setting 设置 Prompt 提示 Sample response 回复样本 API request 接口请求 python接口请求示例 node.js接口请求示 ...
- 基于swiper.js的异型轮播
基于原生swiper.js的异型轮播 <div class="swiper-container" > <div class="swiper-wrappe ...
- 第四部分:Spdlog日志库的核心组件分析-logger
Spdlog是一个快速且可扩展的C++日志库,它支持多线程和异步日志记录.在本文中,我们将分析Spdlog日志库的核心代码,探究其实现原理和代码结构. Spdlog的基本架构 上一篇文章介绍了spdl ...
- SpringBoot中如何实现业务校验,这种方式才叫优雅!
大家好,我是飘渺. 在日常的接口开发中,为了保证接口的稳定安全,我们一般需要在接口逻辑中处理两种校验: 参数校验 业务规则校验 首先我们先看看参数校验. 参数校验 参数校验很好理解,比如登录的时候需要 ...
- JSTL标签fmt:formatDate格式化日期出错
现象&背景: 异常: "org.apache.jasper.JasperException: 在 [115] 行处理 [/WEB-INF/jsp/modules/receivedya ...
- 四月十号java知识点
1.数组:若干个相同数据类型元素按照一定顺序排列的集合2.JAVA语言内存分为栈内存和堆内存3.方法中的一些基本类型变量和对象的引用变量都在方法中的栈内存中分配4.堆内存用来存放new运算符创建的数组 ...
- 补五月三号java基础知识
1.泛型技术可以通过一种类型或方法操纵各种不同类型的对象,同时又提供了编译时的类型安全保证.2.容器(即集合)是以类库形式 提供的多种数据结构,用户在编程时可直接使用3.泛型其实质就是将数据的类型参数 ...
- 【Contest】Nowcoder 假日团队赛1 题解+赛后总结
比赛链接 通过顺序:\(B\rightarrow D\rightarrow I\rightarrow J\rightarrow G\rightarrow H \rightarrow A \righta ...