跨域配置
配置类
| @Configuration |
| public class CorsConfig implements WebMvcConfigurer { |
| |
| @Override |
| public void addCorsMappings(CorsRegistry registry) { |
| registry.addMapping("/**") |
| .allowedOrigins("*") |
| .allowCredentials(true) |
| .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") |
| .maxAge(3600); |
| } |
| } |
Gateway
| spring: |
| cloud: |
| gateway: |
| routes: |
| - id: dedupe_response_header_route |
| uri: https://example.org |
| filters: |
| - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin |

https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#the-deduperesponseheader-gatewayfilter-factory