查资料发现在网关出现503错误是因为全局过滤器没有加载(ReactiveLoadBalancerClientFilter),只需要将含有这个过滤器的依赖进行导入就行了
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
出现404可能是因为没有开启跨域,可以通过注解的方式开启,也可以通过在网关中编写配置文件进行实现
@Bean
public CorsWebFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.addAllowedMethod("*");
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
source.registerCorsConfiguration("/**", config);
return new CorsWebFilter(source);
}
标签:spring,source,404,new,config,503
From: https://www.cnblogs.com/just1t/p/16929764.html