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

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

Introduction

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

Prototype

public void setAllowedHeaders(@Nullable List<String> allowedHeaders) 

Source Link

Document

Set the list of headers that a pre-flight request can list as allowed for use during an actual request.

Usage

From source file:org.ameba.http.PermitAllCorsConfigurationSource.java

/**
 * {@inheritDoc}//  w w w  .j av a  2s. c o  m
 *
 * Returns a pre-configured configuration that allows everything from everywhere.
 */
@Override
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
    CorsConfiguration corsConfiguration = new CorsConfiguration();
    corsConfiguration.addAllowedOrigin("*");
    corsConfiguration.setAllowedMethods(asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
    corsConfiguration.setAllowedHeaders(asList("Content-Type", "X-REQUESTED-WITH", "Authorization"));
    corsConfiguration.setMaxAge(1800L);
    return corsConfiguration;
}