Enable CORS for /health endpoint in Spring Boot Actuator
There are a few properties that can be used to enable CORS for the actuator's endpoints. For example, to allow GET
requests from example.com
in Spring Boot 1.x:
endpoints.cors.allowed-origins=http://example.com
endpoints.cors.allowed-methods=GET
and for Spring Boot 2:
management.endpoints.web.cors.allowed-origins=http://example.com
management.endpoints.web.cors.allowed-methods=GET
Spring boot 2:
You need to add the allow OPTIONS and allow headers as follows
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.allowed-methods=OPTIONS, GET, POST
management.endpoints.web.cors.allowed-headers=*