当前位置:网站首页>When allowCredentials is true, allowedOrigins cannot contain the special value “*“ since that canno
When allowCredentials is true, allowedOrigins cannot contain the special value “*“ since that canno
2022-04-22 14:35:00 【闲言博客】
错误产生环境
SpringBoot实现 WebMvcConfigurer 接口解决跨域问题时产生
错误描述
Caused by: java.lang.IllegalArgumentException: When allowCredentials is true,
allowedOrigins cannot contain the special value "*" since that cannot be set on the
"Access-Control-Allow-Origin" response header. To allow credentials to a set of origins,
list them explicitly or consider using "allowedOriginPatterns" instead.
错误原因
解决办法
将 .allowedOrigins("*") 改为 .allowedOriginPatterns("*")
修改前
@Override
public void addCorsMappings(CorsRegistry corsRegistry){
/** * 所有请求都允许跨域,使用这种配置就不需要 * 在interceptor中配置header了 */
corsRegistry.addMapping("/**")
//是否发送Cookie
.allowCredentials(true)
//放行哪些原始域
.allowedOrigins("*")
.allowedMethods(new String[]{
"GET", "POST", "PUT", "DELETE"})
.allowedHeaders("*");
}
修改后
@Override
public void addCorsMappings(CorsRegistry corsRegistry){
/** * 所有请求都允许跨域,使用这种配置就不需要 * 在interceptor中配置header了 */
corsRegistry.addMapping("/**")
//是否发送Cookie
.allowCredentials(true)
//放行哪些原始域
.allowedOriginPatterns("*")
.allowedMethods(new String[]{
"GET", "POST", "PUT", "DELETE"})
.allowedHeaders("*");
}
版权声明
本文为[闲言博客]所创,转载请带上原文链接,感谢
https://bloghut.blog.csdn.net/article/details/124282813
边栏推荐
- 快速整明白Redis中的字典到底是个啥
- ArcEngine cannot find this item in this collection
- Android 92022-2022 byte beating Android interview real question analysis
- interrupted()和isInterrupted()详述,百万数据分页查询的方法及其优化方式
- Fundamentals of database (II)
- gradle 引用平级项目
- LeetCode_ 63 different paths II
- 世界读书日晒出你的书单,有机会领取免费读书年卡!
- How do I copy requests from the Chrome web tab to postman?
- Collection class
猜你喜欢

Arcengine点,线,面,文本渲染

Interrupted () and isinterrupted () detail the method of paging query of millions of data and its optimization method

【ELT.ZIP】《CCF开源高校行第一期》观后感
2020 popular whole network series: This is a very suitable Android advanced - interview key and difficult data notes for collection and collection! Continuously update the high-quality interview links

Spark code spark submit submit submit yarn cluster mode

Huawei cloud media Zha Yong: Huawei cloud's technical practice in the field of video AI transcoding

每周问答精选:PolarDB-X完全兼容MySQL吗?

自动化测试的生命周期是什么?

@Resources and constructors

Completion of minmao e-commerce in 10 days - Implementation of user module (2nd day)
随机推荐
集合类
天梯赛--L2-002 链表去重 (25 分)
2020火爆全网系列:这是一份非常适合领取与收藏的Android进阶-面试重难点资料笔记!持续更新大厂高质量面试链接
VDO virtual data optimization
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
MySQL面试题汇总-55题
Difference between NPM install -- save and NPM install -- save dev
postMassage留个坑
Arcengine 自定义工具鼠标样式设置
Android interview: event distribution 8 consecutive questions, Android basic interview questions
ITopologicalOperator使用说明
天梯赛--L2-004 这是二叉搜索树吗? (25 分)(递归)
It people should not only improve their earning ability, but also expand their ways of making money. The "immortal document" released by Tencent's technical officer is a hot network
Apache iotdb's UDF source code analysis (1)
PIP command and online and offline installation method
做好安全测试的方法
ArcEngine服务数据加载
5 minutes to understand the internal implementation of redis QuickList
【ELT.ZIP】OpenHarmony啃论文俱乐部——综述视角解读压缩编码
Knowledge is power, but more importantly, the ability to use knowledge - wechat code scanning payment on the web - technical design