reactjs + spring安全性,注册部分失败,出现403错误

时间:2018-11-12 14:38:46

标签: reactjs spring-boot spring-security

@Configuration
public class CorsConfiguration {

  @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**").allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH").allowedOrigins("*")
                .allowedHeaders("*");
            }
        };
    }

}

 @Override
protected void configure(HttpSecurity http) throws Exception {

    http.cors()
    .and().csrf()
    .disable().authorizeRequests().antMatchers("/",
             "/favicon.ico",
             "/**/*.png",
             "/**/*.gif",
             "/**/*.svg",
             "/**/*.jpg",
             "/**/*.html",
             "/**/*.css",
             "/**/*.js")
             .permitAll()
             .antMatchers("/registration", "/login")
             .permitAll().anyRequest()
             .authenticated();;
}

enter image description here

从reactjs发送请求时,我在屏幕截图中看到了错误。我认为这与CrossOrigin问题有关。请帮助

0 个答案:

没有答案
相关问题