Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package config;
  2.  
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.web.servlet.config.annotation.CorsRegistry;
  6. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  7. import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  8.  
  9. /**
  10. * Configures CORS globally.
  11. */
  12. @Configuration
  13. public class WebConfig {
  14.  
  15. @Bean
  16. public WebMvcConfigurer corsConfigurer() {
  17. return new WebMvcConfigurerAdapter() {
  18. @Override
  19. public void addCorsMappings(CorsRegistry registry) {
  20. registry.addMapping("/**")
  21. // allow all methods, since only GET, POST, and HEAD are allowed by default
  22. .allowedMethods("*");
  23. }
  24. };
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement