When allowCredentials is true, allowedOrigins cannot contain the special value “*“ that cannot be
SpringBoot升级2.4.0所出现的问题:
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即可。
调整前:
package com.course.server.config;import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration
public class CorsConfig implements WebMvcConfigurer {@Overridepublic void addCorsMappings(CorsRegistry registry) {// 设置允许跨域的路由registry.addMapping("/**")// 设置允许跨域请求的域名.allowedOrigins("*").allowedHeaders(CorsConfiguration.ALL)// 设置允许的方法.allowedMethods(CorsConfiguration.ALL)// 是否允许证书(cookies).allowCredentials(true)// 跨域允许时间.maxAge(3600);//1小时内不需要校验,发送OPTIONS请求}
}
调整后:
package com.course.server.config;import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration
public class CorsConfig implements WebMvcConfigurer {@Overridepublic void addCorsMappings(CorsRegistry registry) {// 设置允许跨域的路由registry.addMapping("/**")// 设置允许跨域请求的域名.allowedOriginPatterns("*").allowedHeaders(CorsConfiguration.ALL)// 设置允许的方法.allowedMethods(CorsConfiguration.ALL)// 是否允许证书(cookies).allowCredentials(true)// 跨域允许时间.maxAge(3600);//1小时内不需要校验,发送OPTIONS请求}
}
When allowCredentials is true, allowedOrigins cannot contain the special value “*“ that cannot be相关推荐
- 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 ...
- 【SpringBoot】升级2.4.0所出现的问题:When allowCredentials is true, allowedOrigins cannot contain the specia
项目场景: 提示:这里简述项目相关背景: 保留现场: When allowCredentials is true, allowedOrigins cannot contain the special ...
- SpringBoot升级所出现的问题:When allowCredentials is true, allowedOrigins cannot contain the specia
错误信息如下 When allowCredentials is true, allowedOrigins cannot contain the special value "*" ...
- Springboot跨域配置报错:When allowCredentials is true, allowedOrigins cannot contain the specia
错误信息为: When allowCredentials is true, allowedOrigins cannot contain thespecial value "*"si ...
- 跨域 问题:When allowCredentials is true, allowedOrigins cannot contain the specia
解决办法:跨域配置报错,将.allowedOrigins替换成.allowedOriginPatterns即可. 修改前 @Configuration public class WebMvcConfi ...
- When allowCredentials is true, allowedOrigins cannot contain the specia 跨域 网关跨域
解决办法:跨域配置报错,将.allowedOrigins替换成.allowedOriginPatterns即可. SpringBoot2.0.0中 @Configuration public clas ...
- Springboot 跨域配置
访问后端接口遇到错误提示: When allowCredentials is true, allowedOrigins cannot contain the special value "* ...
- Spring Boot整合Shiro + Springboot +vue
目录 02 Spring Boot整合Shiro p1.shiro概述 1 什么是Shiro 2 Shiro核心组件 p2.Shiro实现登录认证 AccountRealm.java QueryWra ...
- springcloud微服务中跨域配置
跨域,指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器对 javascript 施加的安全限制. 同源策略,指的是协议,域名,端口都要相同,其中有一个不同都会产生跨域. 跨域 ...
最新文章
- 中国雪糕红黑榜,谁才是Top 1
- 做砸数据中台项目的9种方法
- 如何解决:Android中 Error generating final archive: Debug Certificate expired on 的错误
- 导数,微积分,牛顿运动学制作创意地图
- java map 不存在的key_java – HashMap表示即使它确实存在,Key也不存在
- Java开发环境!java基础知识点总结
- wex5部署教程到数据库
- 剑指offer-JZ82 二叉树中和为某一值的路径(一)(附区分DFS和回溯)
- document.cookie 获取不到_意想不到,王者荣耀中不用花钱就可以获得的皮肤有哪
- TCC-Transaction TCC 实现
- kb4023057安装失败_微软向旧版Windows 10推送易升补丁出现无法安装问题
- 帝国败局:一代首富,因何退隐江湖?
- ucwords和ucfirst用法举例!!
- 从300行文件系统的实现内窥Linux VFS组织
- 一元二次方程组的简单解法
- 华中科技大学组原实验记录 运算器ALU实验
- 计算机文档打不开是什么原因,电脑文件打不开怎么回事
- position属性详解
- 儿时的情怀除了教材的封面和王心凌的《爱你》,还有证件照上的红领巾和马尾辫
- win7 计算器的用法