您当前的位置: 首页 >  gateway

水的精神

暂无认证

  • 2浏览

    0关注

    711博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

gateway网关统一解决跨域问题

水的精神 发布时间:2021-03-04 10:50:50 ,浏览量:2

网上有很多种解决跨域问题的,只有这种用起来最简单。

通过修改配置文件的方式来解决。

 只需要在  application.yml 配置文件中添加红色框的配置:

 

spring:
  application:
    name: app-gateway
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
    gateway:
      globalcors:
        corsConfigurations:
          '[/**]':
            allowedHeaders: "*"
            allowedOrigins: "*"
            allowCredentials: true
            allowedMethods:
              - GET
              - POST
              - DELETE
              - PUT
              - OPTION

 

 

最后需要注意一点,既然是在网关里边来解决跨域问题的,就不能在下流的服务里边再重复引入解决跨域的配置了。否则会导致跨域失效,报跨域的问题。

关注
打赏
1664074814
查看更多评论
立即登录/注册

微信扫码登录

0.0506s