springcloud网关跨域问题和转发服务的配置

  • 只需要在yml文件中添加此配置即可
spring:
application:
name: gateway-web
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]': # 匹配所有请求
allowedOrigins: "*" #跨域处理 允许所有的域
allowedMethods: # 支持的方法
- GET
- POST
- PUT
- DELETE
  • 转发服务的配置
spring:
application:
name: gateway-web
cloud:
gateway:
routes:
- id: changgou_goods_route
uri: lb://goods
predicates:
- Path=/api/album/**,/api/brand/**,/api/cache/**
filters:
#- PrefixPath=/brand
- StripPrefix=1
#用户微服务

猜你喜欢

转载自www.cnblogs.com/shangyunlin/p/12815300.html