Reputation: 11
Using Spring Boot 2.0.2
- How do we suppress or hide Access-Control-Allow-Methods
header field in preflight response.
I have a custom CORS
filter which adds this header to the response.This is a part of requirement for a penetration testing.Any guidance will be helpful.
Upvotes: 0
Views: 792
Reputation: 3288
You can override addCorsMappings
method of WebMvcConfigurerAdapter
to control what CORS headers are going to be sent to the client:
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE").allowedOrigins("*")
.allowedHeaders("*");
}
}
Upvotes: 1