@@ -81,7 +81,8 @@ public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder(List<Serializatio
8181 @ Bean
8282 public WebMvcConfigurer corsConfigurer (List <CorsPathPatternProvider > configurationUrlProviders ,
8383 @ Value ("${basyx.cors.allowed-origins:}" ) String [] allowedOrigins ,
84- @ Value ("${basyx.cors.allowed-methods:}" ) String [] allowedMethods ) {
84+ @ Value ("${basyx.cors.allowed-methods:}" ) String [] allowedMethods ,
85+ @ Value ("${basyx.cors.allowed-headers:}" ) String [] allowedHeaders ) {
8586 return new WebMvcConfigurer () {
8687 @ Override
8788 public void addCorsMappings (CorsRegistry registry ) {
@@ -91,15 +92,30 @@ public void addCorsMappings(CorsRegistry registry) {
9192 logger .info ("---- Configuring CORS ----" );
9293
9394 for (CorsPathPatternProvider provider : configurationUrlProviders ) {
94- configureOrigins (allowedOrigins , allowedMethods , registry , provider .getPathPattern ());
95+ configureOrigins (
96+ allowedOrigins ,
97+ allowedMethods ,
98+ allowedHeaders ,
99+ registry ,
100+ provider .getPathPattern ()
101+ );
95102 }
96103 }
97104
98- private void configureOrigins (String [] allowedOrigins , String [] allowedMethods , CorsRegistry registry , String pathPattern ) {
105+ private void configureOrigins (
106+ String [] allowedOrigins ,
107+ String [] allowedMethods ,
108+ String [] allowedHeaders ,
109+ CorsRegistry registry ,
110+ String pathPattern
111+ ) {
99112 logger .info (pathPattern + " configured with allowedOriginPatterns " + Arrays .toString (allowedOrigins ));
100113 logger .info (allowedMethods .length == 0 ? "No allowed methods configured" : pathPattern + " configured with allowedMethods " + Arrays .toString (allowedMethods ));
101114
102- registry .addMapping (pathPattern ).allowedOriginPatterns (allowedOrigins ).allowedMethods (allowedMethods );
115+ registry .addMapping (pathPattern )
116+ .allowedOriginPatterns (allowedOrigins )
117+ .allowedMethods (allowedMethods )
118+ .allowedHeaders (allowedHeaders );
103119 }
104120 };
105121 }
0 commit comments