Skip to content

Commit c15418b

Browse files
committed
Update actuator support to ensure CORS properties always apply
Update `AbstractWebFluxEndpointHandlerMapping` and `AbstractWebMvcEndpointHandlerMapping` to ensure cors configuration is applied. See gh-45487
1 parent 1f53f1d commit c15418b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -218,6 +218,12 @@ protected CorsConfiguration initCorsConfiguration(Object handler, Method method,
218218
return this.corsConfiguration;
219219
}
220220

221+
@Override
222+
protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange) {
223+
CorsConfiguration corsConfiguration = super.getCorsConfiguration(handler, exchange);
224+
return (corsConfiguration != null) ? corsConfiguration : this.corsConfiguration;
225+
}
226+
221227
@Override
222228
protected boolean isHandler(Class<?> beanType) {
223229
return false;

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -233,6 +233,12 @@ protected CorsConfiguration initCorsConfiguration(Object handler, Method method,
233233
return this.corsConfiguration;
234234
}
235235

236+
@Override
237+
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
238+
CorsConfiguration corsConfiguration = super.getCorsConfiguration(handler, request);
239+
return (corsConfiguration != null) ? corsConfiguration : this.corsConfiguration;
240+
}
241+
236242
@Override
237243
protected boolean isHandler(Class<?> beanType) {
238244
return false;

0 commit comments

Comments
 (0)