在使用SpringCloud Gateway时遇到即使配置了跨域方案,但是还是提示跨域问题,解决方案如下:
在网关添加下面配置代码即可,注:在下层服务不需要在做任何跨域配置,例如注解@CrossOrigin,否则会由于配置冲突导致依然出现跨域问题
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.