1,添加如下代码
http.cors().and().csrf().disable().authorizeRequests()
//处理跨域请求中的Preflight请求
.requestMatchers(CorsUtils::isPreFlightRequest)
.permitAll()
注意,加载最前面不能加在anyrequest后面
1,添加如下代码
http.cors().and().csrf().disable().authorizeRequests()
//处理跨域请求中的Preflight请求
.requestMatchers(CorsUtils::isPreFlightRequest)
.permitAll()
注意,加载最前面不能加在anyrequest后面