gateway里配置跨域类,解决跨域问题


```java
  @Bean
    public CorsWebFilter corsWebFilter(){
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();

        CorsConfiguration corsConfiguration = new CorsConfiguration();

        //1、配置跨域        
        corsConfiguration.addAllowedHeader("*"); // 允许任何头
        corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等)
        corsConfiguration.addAllowedOrigin("*");// 允许任何域名使用
        corsConfiguration.setAllowCredentials(true);//允许携带cookie访问

        source.registerCorsConfiguration("/**",corsConfiguration);
        return new CorsWebFilter(source);
    }


你可能感兴趣的:(java,Sprincloud,java,spring)