Guest User

Untitled

a guest
Jan 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. package io.navan.heroesbackend;
  2.  
  3. import java.util.Arrays;
  4.  
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7. import org.springframework.web.cors.CorsConfiguration;
  8. import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
  9. import org.springframework.web.filter.CorsFilter;
  10.  
  11. @Configuration
  12. public class CorsConfig {
  13. @Bean
  14. public CorsFilter corsFilter() {
  15. CorsConfiguration config = new CorsConfiguration();
  16. config.addAllowedOrigin("*");
  17. config.addAllowedHeader("*");
  18. config.setAllowedMethods(Arrays.asList(
  19. new String[] {"OPTIONS", "GET", "POST", "PUT", "DELETE"}));
  20.  
  21. UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  22. source.registerCorsConfiguration("/**", config);
  23.  
  24. return new CorsFilter(source);
  25. }
  26. }
Add Comment
Please, Sign In to add comment