Example usage for org.springframework.web.cors CorsConfiguration applyPermitDefaultValues

List of usage examples for org.springframework.web.cors CorsConfiguration applyPermitDefaultValues

Introduction

In this page you can find the example usage for org.springframework.web.cors CorsConfiguration applyPermitDefaultValues.

Prototype

public CorsConfiguration applyPermitDefaultValues() 

Source Link

Document

By default a newly created CorsConfiguration does not permit any cross-origin requests and must be configured explicitly to indicate what should be allowed.

Usage

From source file:io.syndesis.runtime.SyndesisCorsConfiguration.java

@Bean
public CorsFilter corsFilter() {
    return new CorsFilter(request -> {
        String pathInfo = request.getPathInfo();
        if (pathInfo != null && (pathInfo.endsWith("/swagger.json") || pathInfo.endsWith("/swagger.yaml"))) {
            return new CorsConfiguration().applyPermitDefaultValues();
        }//from  www.j  a  v a 2s.  c  o m

        CorsConfiguration config = new CorsConfiguration();
        config.setAllowedOrigins(allowedOrigins);
        config.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"));
        config.applyPermitDefaultValues();
        return config;
    });
}