Last active
January 8, 2018 23:26
-
-
Save finsterthecat/d56c5047f05cb47a101d022c729d2034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.navan.heroesbackend; | |
import java.util.Arrays; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.web.cors.CorsConfiguration; | |
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | |
import org.springframework.web.filter.CorsFilter; | |
@Configuration | |
public class CorsConfig { | |
@Bean | |
public CorsFilter corsFilter() { | |
CorsConfiguration config = new CorsConfiguration(); | |
config.addAllowedOrigin("*"); | |
config.addAllowedHeader("*"); | |
config.setAllowedMethods(Arrays.asList( | |
new String[] {"OPTIONS", "GET", "POST", "PUT", "DELETE"})); | |
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | |
source.registerCorsConfiguration("/**", config); | |
return new CorsFilter(source); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment