注意:
如果你在網(wǎng)上看到過(guò)許多關(guān)于springboot解決跨域的問(wèn)題
按照網(wǎng)上說(shuō)的做,然鵝并沒有什么卵用.
恭喜你,是你的springboot版本問(wèn)題
恭喜你,是你的springboot版本問(wèn)題
恭喜你,是你的springboot版本問(wèn)題
萬(wàn)能配置直接無(wú)敵,好吧!!!
/**
* @author Mr_Lin
*/
@Configuration
public class CorsConfig {
@Bean
public CorsFilter corsFilter() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
//1,允許任何來(lái)源
corsConfiguration.setAllowedOriginPatterns(Collections.singletonList("*"));
//2,允許任何請(qǐng)求頭
corsConfiguration.addAllowedHeader(CorsConfiguration.ALL);
//3,允許任何方法
corsConfiguration.addAllowedMethod(CorsConfiguration.ALL);
//4,允許憑證
corsConfiguration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(source);
}
}
不管用你來(lái)找我,雖然你也找不到我!!!
????????????????????????????????