对GateWay网关进行记录。
跨域请求
使用Spring Cloud 和 Vue 前后端交互时,需要把跨域请求配置到网关里,否则会报跨域请求错误。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| gateway: globalcors: add-to-simple-url-handler-mapping: true corsConfigurations: '[/**]': allowedHeaders: "*" allowedOrigins: "*" allowedMethods: - "GET" - "POST" - "DELETE" - "PUT" - "OPTIONS" allowCredentials: true maxAge: 360000
|
路由拦截
可以对路由进行404重定向拦截
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| routes: - id: user_router uri: lb://isrp-user predicates: - Path=/isrpUser/** - id: goods_router uri: lb://isrp-goods predicates: - Path=/isrpGoods/** - id: auth_router uri: lb://isrp-auth predicates: - Path=/isrpAuth/**
- id: gateway_404 uri: lb://isrp-gateway predicates: - Path=/** filters: - RedirectTo=302, http://localhost:9527/
|