Created
September 16, 2024 04:43
-
-
Save unclebean/9eef9b2330412ece5ac438922d536936 to your computer and use it in GitHub Desktop.
Cora
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 | |
public CorsConfigurationSource corsConfigurationSource() { | |
CorsConfiguration configuration = new CorsConfiguration(); | |
configuration.setAllowedOrigins(List.of("*")); // Allow all origins, or specify specific ones | |
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS")); // Allow all methods | |
configuration.setAllowedHeaders(List.of("*")); // Allow all headers | |
configuration.setAllowCredentials(true); // Allow credentials like cookies | |
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | |
source.registerCorsConfiguration("/**", configuration); // Apply CORS config to all endpoints | |
return source; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment