application.yml 文件里配置

#路由规则 负载均衡和网关跨域问题的配置如下:
spring:
  cloud:
    gateway:  # 以下为路由规则:
      routes:
        - id: gulimall-pms_route
          uri: lb://gulimall-pms
          predicates:
            - Path=/pms/**

        - id: gulimall-oms_route
          uri: lb://gulimall-oms
          predicates:
            - Path=/oms/**

        - id: gulimall-sms_route
          uri: lb://gulimall-sms
          predicates:
            - Path=/sms/**

        - id: gulimall-ums_route
          uri: lb://gulimall-ums
          predicates:
            - Path=/ums/**

        - id: gulimall-wms_route
          uri: lb://gulimall-wms
          predicates:
            - Path=/wms/**
        #以下为 跨域配置
      default-filters:
        - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE
      globalcors:
        cors-configurations:
          '[/**]': 
            allow-credentials: true # 允许携带认证信息
            allowedOrigins: "*"    # 允许跨域的源(网站域名/ip),设置*为全部
            allowedMethods: "*"   # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部
            allowedHeaders: "*"   # 允许跨域请求里的head字段,设置*为全部
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐