zuul如何解决前后端分离的跨域问题

前端用的vue2,前后端分离
这个zuul这里要怎么设置呢?
做反向代理的话要怎么设置?
已邀请:

qiuxiaozhang - 95后it男

赞同来自: 许进 snakebark

Zuul里面加入以下代码
@bean
@Order(Integer.MAX_VALUE)
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
final CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowCredentials(true);
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(urlBasedCorsConfigurationSource);
}

要回复问题请先登录注册