From 5e83e5dbdd130eabc863ef03328fb1c131940bc5 Mon Sep 17 00:00:00 2001 From: gaowdong Date: Wed, 25 Jun 2025 16:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=89=AB=E6=8F=8F=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/bonus/gateway/config/GlobalCorsConfig.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java b/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java index 31cc812..a79daaa 100644 --- a/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java +++ b/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java @@ -1,7 +1,9 @@ package com.bonus.gateway.config; import cn.hutool.core.collection.CollUtil; +import com.alibaba.nacos.common.utils.JacksonUtils; import com.bonus.gateway.config.properties.CorsProperties; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,6 +16,7 @@ import org.springframework.web.util.pattern.PathPatternParser; * Description: 全局跨域配置 */ @Configuration +@Slf4j public class GlobalCorsConfig { @Autowired private CorsProperties corsProperties; @@ -24,6 +27,7 @@ public class GlobalCorsConfig { // 允许所有的HTTP请求方法(GET, POST, PUT, DELETE等) config.addAllowedMethod("*"); // 允许所有的域名发起的请求 比如http://localhost:8080、 + log.info("允许的域名:{}", corsProperties.getAllowedOrigins()); if(CollUtil.isNotEmpty(corsProperties.getAllowedOrigins())) { for(String cors : corsProperties.getAllowedOrigins()) { config.addAllowedOrigin(cors);