Spring Boot2.1.3全局跨域

  /**
     * 配置跨域访问
     *
     * @author Terwer
     */
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/api/**")
                        .allowedOrigins("*")
                        .allowCredentials(true)
                        .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH")
                        .maxAge(3600);
            }
        };
    }
posted @ 2019-03-22 16:20  灯塔下的守望者  阅读(575)  评论(0编辑  收藏  举报