SpringBoot/JWT应用程序允许在浏览器中拒绝访问,但在postman中有效。为什么?

SpringBoot/JWT应用程序允许在浏览器中拒绝访问,但在postman中有效。为什么?,spring,spring-boot,jwt,Spring,Spring Boot,Jwt,我们正在使用Swagger和,我们需要使用浏览器来显示Swagger文档。但由于某些原因,JWT不允许chrome访问应用程序,并拒绝访问 我们按照本教程学习JWT,这就是cors选项方法问题。您需要授予访问选项方法 在安全方面试试这个 public class CustomSecurity extends WebSecurityConfigurerAdapter{ @Override protected void configure(HttpSecurity http) throws

我们正在使用Swagger和,我们需要使用浏览器来显示Swagger文档。但由于某些原因,JWT不允许chrome访问应用程序,并拒绝访问


我们按照本教程学习JWT,这就是cors选项方法问题。您需要授予访问选项方法 在安全方面试试这个

public class CustomSecurity extends WebSecurityConfigurerAdapter{

  @Override
  protected void configure(HttpSecurity http) throws Exception { 
      http.csrf()
        .disable()
        .authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll() ....

}
}

可能是CORS问题您需要允许CORS(选项)方法