参考

  1. Springboot处理CORS跨域请求的三种方法

代码

  • config/创建 CorsConfig.java
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    static final String ORIGINS[] = new String[] { "GET", "POST", "PUT", "DELETE" };
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedMethods(ORIGINS).maxAge(3600);
    }

}

相关文章:

  • 2021-08-07
  • 2021-09-08
  • 2022-12-23
  • 2021-11-04
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2021-08-06
  • 2021-07-20
  • 2021-11-05
相关资源
相似解决方案