Created
May 5, 2021 13:16
-
-
Save walidum/cef8a4cc6eaef2d8d85de22ec2034c81 to your computer and use it in GitHub Desktop.
To enable CORS in the WebFlux Java configuration, you can use the CorsRegistry callback, as the following example shows:
This file contains 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
@Configuration | |
@EnableWebFlux | |
public class WebConfig implements WebFluxConfigurer { | |
@Override | |
public void addCorsMappings(CorsRegistry registry) { | |
registry.addMapping("/api/**") | |
.allowedOrigins("https://domain2.com") | |
.allowedMethods("PUT", "DELETE") | |
.allowedHeaders("header1", "header2", "header3") | |
.exposedHeaders("header1", "header2") | |
.allowCredentials(true).maxAge(3600); | |
// Add more mappings... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment