Created
August 21, 2019 17:21
-
-
Save timjonesdev/de2d8feb477954eeffb5765bf0ec714a to your computer and use it in GitHub Desktop.
A simple CORS filter
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
| @Bean | |
| CorsWebFilter corsFilter() { | |
| CorsConfiguration config = new CorsConfiguration(); | |
| // Possibly... | |
| // config.applyPermitDefaultValues() | |
| config.setAllowCredentials(true); | |
| // allow access to my dev Angular instance | |
| config.addAllowedOrigin("http://localhost:4200"); | |
| config.addAllowedHeader("*"); | |
| config.addAllowedMethod("*"); | |
| UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | |
| source.registerCorsConfiguration("/**", config); | |
| return new CorsWebFilter(source); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment