【问题标题】:Spring Boot Actuator with cors support and options request具有 cors 支持和选项请求的 Spring Boot Actuator
【发布时间】:2016-06-26 22:23:17
【问题描述】:

我有支持 cors 的 Spring Boot Actuator,它在 application.properties 中配置如下:

management.context-path=/management

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

当我尝试使用任何标头向此路径发送请求时,我总是收到此错误

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

GET 请求工作正常。我做错了什么?

【问题讨论】:

    标签: cors spring-boot-actuator http-options-method


    【解决方案1】:

    配置没问题,一切正常。问题出在请求路径中。当您使用 AccessControlRequestMethod != GET 将预检请求发送到 /managment/*(/health 除外)时,会发生此异常。 我认为这是正常行为,但如果它抛出 403 而不是 405 会更容易理解

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-19
      • 2019-03-26
      • 2021-09-11
      • 2020-05-29
      • 2021-04-15
      • 2019-12-26
      • 2018-06-03
      • 2014-05-15
      相关资源
      最近更新 更多