Spring Boot 2.0 解决跨域问题:WebMvcConfiguration implements WebMvcConfigurer

When allowCredentials is true, allowedOrigins cannot contain the special value "*"since that cannot
复制代码
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时,allowingOrigins不能包含特殊值" *",因为无法在" Access-Control-Allow-Origin"响应标头上设置。

处理方法是:首先找打你后端跨域设置文件,将方法中的addAllowedOrigin("")替换成addAllowedOriginPattern("")


相关推荐
一只叫煤球的猫16 小时前
从 Java 21 到 Java 25:ThreadLocal 以外的选择—— ScopedValue
java·后端·架构
用户31693538118316 小时前
SpringBoot + Vue 项目生产环境部署完整指南
前端·后端
步行cgn16 小时前
MyBatis 多对一关联映射详解
java
仍然.17 小时前
SpringCloud---Eureka介绍
java·spring cloud·eureka
霸道流氓气质17 小时前
Spring 事务同步机制 —— AfterTransactionActionCollector 的异步解耦原理
java·后端·spring
Lightpwd17 小时前
PostgreSQL jsonb 写入踩坑:一条 `\u0000` 如何让整批同步失败,还把异常伪装成“数据完整性冲突”
java
Csvn17 小时前
📊 SQL 入门 Day 19:事务与隔离级别
后端·sql
周周哈哈哈17 小时前
线程创建、执行、退出、回收
java·开发语言
云边有个稻草人17 小时前
飞算JavaAI能处理SaaS套餐变更业务吗?
java·springboot·ai编程·java开发·飞算javaai·java代码生成·ai coding模型