feat(gateway): 配置跨域

This commit is contained in:
Bunny 2025-02-10 23:06:18 +08:00
parent 0acd71150e
commit 22bcf26694
2 changed files with 11 additions and 0 deletions

View File

@ -6,10 +6,12 @@ import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@Slf4j
@Component
public class RouterGlobalFilter implements GlobalFilter, Ordered {
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

View File

@ -1,6 +1,15 @@
spring:
cloud:
gateway:
globalCors:
cors-configurations:
'[/**]':
allowed-origin-patterns:
- "*"
allowed-headers:
- "*"
allowed-methods:
- "*"
routes:
- id: service-baidu
uri: https://www.baidu.com