dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Jun 21, 2017

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


CORS Support in Spring

Spring MVC has implicit CORS support, so to use the controller method CORS configuration with @CrossOrigin annotation in your Spring Boot application does not require any specific configuration.

The global CORS configuration can be defined by registering a WebMVCConfigurer bean with a customized addCorsMappings(CorsRegistry) method, as you can see in the code below:

@Configuration
public class MyConfiguration {

     @Bean
     public WebMvcConfigurer corsConfigurer() {
            return new WebMvcConfigurerAdapter()  {
                @Override
                public void addCorsMappings(CorsRegistry registry) {
                          registry.addMapping("/api/**");
                }
            };
    }
}
Octavia Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date