diff --git a/backend/ruoyi-admin/src/main/resources/application.yml b/backend/ruoyi-admin/src/main/resources/application.yml index 3e4be1dc..131ebc20 100644 --- a/backend/ruoyi-admin/src/main/resources/application.yml +++ b/backend/ruoyi-admin/src/main/resources/application.yml @@ -130,8 +130,6 @@ sa-token: # security配置 security: - # 允许跨域访问的来源(支持 * 通配子域名与 [*] 通配端口);前端均经 nginx 同源访问 /prod-api,新增域名时在此补充 - cors-allowed-origins: "http://*.hzdyjsxy.cn:[*],https://*.hzdyjsxy.cn:[*],http://localhost:[*],http://127.0.0.1:[*]" # 排除路径(P0:已下线 Swagger/api-docs,不再加入白名单) excludes: - /*.html diff --git a/backend/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java b/backend/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java index cdfe1867..e3b022bd 100644 --- a/backend/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java +++ b/backend/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java @@ -1,7 +1,5 @@ package org.dromara.common.web.config; -import java.util.List; -import org.springframework.beans.factory.annotation.Value; import org.dromara.common.web.handler.GlobalExceptionHandler; import org.dromara.common.web.interceptor.PlusWebInvokeTimeInterceptor; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -35,11 +33,11 @@ public class ResourcesConfig implements WebMvcConfigurer { * 跨域配置 */ @Bean - public CorsFilter corsFilter(@Value("${security.cors-allowed-origins:http://localhost:[*],http://127.0.0.1:[*]}") List allowedOrigins) { + public CorsFilter corsFilter() { CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); - // 设置访问源地址(仅允许配置的本校域名,禁止回显任意 Origin) - allowedOrigins.forEach(config::addAllowedOriginPattern); + // 设置访问源地址(恢复为原通配,避免生产域名/IP 不匹配导致整站接口被浏览器拦截) + config.addAllowedOriginPattern("*"); // 设置访问源请求头 config.addAllowedHeader("*"); // 设置访问源请求方法