错误信息为:

When allowCredentials is true, allowedOrigins cannot contain thespecial 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.

大概意思是:allowCredentials为true时,allowedOrigins不能包含特殊值“*”,因为不能在“Access Control Allow Origin”响应头上设置该值。要允许凭据指向一组源,请显式列出它们,或者考虑改用“allowedOriginPatterns”。

所以解决办法:将.allowedOrigins替换成.allowedOriginPatterns即可。

修改前:

//全局配置类--配置跨域请求
@Configuration
public class CrosConfig implements WebMvcConfigurer {static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE","OPTIONS"};@Overridepublic void addCorsMappings(CorsRegistry registry) {registry.addMapping("/**") // 所有的当前站点的请求地址,都支持跨域访问。.allowedOrigins("*") // 所有的外部域都可跨域访问。 如果是localhost则很难配置,因为在跨域请求的时候,外部域的解析可能是localhost、127.0.0.1、主机名.allowCredentials(true) // 是否支持跨域用户凭证.allowedMethods(ORIGINS) // 当前站点支持的跨域请求类型是什么.maxAge(3600); // 超时时长设置为1小时。 时间单位是秒。}
}

该版本用于springboot2.0.0中

修改后:

//全局配置类--配置跨域请求
@Configuration
public class CrosConfig implements WebMvcConfigurer {static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE","OPTIONS"};@Overridepublic void addCorsMappings(CorsRegistry registry) {registry.addMapping("/**") // 所有的当前站点的请求地址,都支持跨域访问。.allowedOriginPatterns("*") // 所有的外部域都可跨域访问。 如果是localhost则很难配置,因为在跨域请求的时候,外部域的解析可能是localhost、127.0.0.1、主机名.allowCredentials(true) // 是否支持跨域用户凭证.allowedMethods(ORIGINS) // 当前站点支持的跨域请求类型是什么.maxAge(3600); // 超时时长设置为1小时。 时间单位是秒。}
}

该版本用于springboot2.4.0中

Springboot跨域配置报错:When allowCredentials is true, allowedOrigins cannot contain the specia相关推荐

  1. When allowCredentials is true, allowedOrigins cannot contain the specia 跨域 网关跨域

    解决办法:跨域配置报错,将.allowedOrigins替换成.allowedOriginPatterns即可. SpringBoot2.0.0中 @Configuration public clas ...

  2. 跨域 问题:When allowCredentials is true, allowedOrigins cannot contain the specia

    解决办法:跨域配置报错,将.allowedOrigins替换成.allowedOriginPatterns即可. 修改前 @Configuration public class WebMvcConfi ...

  3. SpringBoot升级2.4.0所出现的问题:When allowCredentials is true, allowedOrigins cannot contain the specia

    When allowCredentials is true, allowedOrigins cannot contain the special value "*"since th ...

  4. 【SpringBoot】升级2.4.0所出现的问题:When allowCredentials is true, allowedOrigins cannot contain the specia

    项目场景: 提示:这里简述项目相关背景: 保留现场: When allowCredentials is true, allowedOrigins cannot contain the special ...

  5. SpringBoot升级所出现的问题:When allowCredentials is true, allowedOrigins cannot contain the specia

    错误信息如下 When allowCredentials is true, allowedOrigins cannot contain the special value "*" ...

  6. Springboot 跨域配置

    访问后端接口遇到错误提示: When allowCredentials is true, allowedOrigins cannot contain the special value "* ...

  7. springboot 跨域配置cors

    撸了今年阿里.头条和美团的面试,我有一个重要发现.......>>> 1 跨域的理解 跨域是指:浏览器A从服务器B获取的静态资源,包括Html.Css.Js,然后在Js中通过Ajax ...

  8. 【跨域】跨域原理 + springboot跨域配置(万能版)

    先上配置 这个配置是个万能药,配上之后就没有任何跨域问题了. @Configuration public class MvcConfig implements WebMvcConfigurer {@B ...

  9. 报错:uni-app跨域请求报错

    编辑器:HBuilderX 语言架构:uni-app + uview+ luch-Request 报错情况:本地运行后端 jar 包,列表页面访问没有问题,打开子组件详情页却跨域错误.但是换台电脑的情 ...

最新文章

  1. 博客开通第一天,加油
  2. 科技垄断正在朝着纵向发展
  3. .NET零基础入门06:面向对象入门
  4. Mac 设置文件默认打开方式
  5. 较复杂js的书写格式
  6. MFC创建单文档工程(左上角名称前的mfc图标修改为其他需求图标)
  7. Matplotlib 可视化之箭头与标注的高级应用
  8. g++ vscode 环境选择_Visual Studio Code 配置C/C++环境
  9. 类的加载过程三:Initialization
  10. 桩筏有限元中的弹性板计算_PKPM2010年11月结构技术问题汇总
  11. Lucas+阶乘打表+费马小定理模板2.0
  12. 使用半透明的DIV实现禁用页面功能
  13. 无比强悍的CRM营销模块,SuiteCRM功能介绍
  14. html拾色器没效果,用html和js写一个拾色器
  15. XCTF-攻防世界-密码学crypto-新手练习区-writeup
  16. 单招软件职业技能测试,招生信息网-2019年单独招生《职业技能测试》考试大纲...
  17. html 中数字一直往上加的动态效果,CSS动画:数字增量效果
  18. 华为手机html乱码,华为手机语言设置中文
  19. 剑指Offer:一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法
  20. 蓝桥ROS机器人之C++基础开发第一个程序

热门文章

  1. MySQL中修改密码及访问限制
  2. 阿里云推送 SDK iOS 端 配置
  3. 引入阿里云SDK,类找不到的问题
  4. CHOPS 音乐驱动动画2
  5. nmap与hydra
  6. 单样本t检验中指标分析
  7. 有关人工智能的硕士点整理
  8. GS1条形码为什么那么贵?有什么便宜的办法吗?
  9. MTK android 9.0半屏显示 单手模式
  10. 【OpenSSL 之五】:HMAC算法分析