Loading
0

spring security 不拦截跨域请求

在spring boot 应用中引入了spring security,当出现跨域的OPTIONS请求时,发现被拦截,加入下面设置可实现对OPTIONS请求的放行。

@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {    
      http.authorizeRequests().
      requestMatchers(CorsUtils::isPreFlightRequest).
      permitAll();
    }
}

最后编辑于:2019/11/20作者: joycode

我不入地狱,谁入地狱?

评论已关闭