Search code examples
corsspring-boot-actuatorhttp-options-method

Spring Boot Actuator with cors support and options request


I have Spring Boot Actuator with cors support, which configurated in application.properties like this:

management.context-path=/management

endpoints.cors.allowed-origins=*
endpoints.cors.allowed-methods=GET,OPTIONS
endpoints.cors.allowed-headers=*

When i try to send request to this path with any headers I always get this error

 org.springframework.web.servlet.PageNotFound - Request method 'OPTIONS' not supported

GET request works fine. What I am doing wrong ?


Solution

  • Configuration is ok, all works fine. The problem was in request path. When you send preflight request with AccessControlRequestMethod != GET to /managment/* (except /health) this exception occures. I think this is normal behavior, but it would be more understandable, if it throws 403, not 405