feat(gateway): 配置跨域
This commit is contained in:
parent
0acd71150e
commit
22bcf26694
|
@ -6,10 +6,12 @@ import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Component
|
||||||
public class RouterGlobalFilter implements GlobalFilter, Ordered {
|
public class RouterGlobalFilter implements GlobalFilter, Ordered {
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
spring:
|
spring:
|
||||||
cloud:
|
cloud:
|
||||||
gateway:
|
gateway:
|
||||||
|
globalCors:
|
||||||
|
cors-configurations:
|
||||||
|
'[/**]':
|
||||||
|
allowed-origin-patterns:
|
||||||
|
- "*"
|
||||||
|
allowed-headers:
|
||||||
|
- "*"
|
||||||
|
allowed-methods:
|
||||||
|
- "*"
|
||||||
routes:
|
routes:
|
||||||
- id: service-baidu
|
- id: service-baidu
|
||||||
uri: https://www.baidu.com
|
uri: https://www.baidu.com
|
||||||
|
|
Loading…
Reference in New Issue