--- title: "无法调度 OPTIONS 请求,因为它们未经过身份验证 - 如何解决此 Elasticsearch 异常" date: 2026-02-27 lastmod: 2026-02-27 description: "当向Elasticsearch发送未经过身份验证的OPTIONS HTTP请求时会出现此错误。本文介绍了多种解决方案,包括提供有效凭证、配置允许未认证的OPTIONS请求、使用API密钥或代理服务器等。" tags: ["身份验证", "OPTIONS请求", "HTTP请求", "安全配置", "异常处理"] summary: " 版本: 8.9-8.9 简而言之,当向 Elasticsearch 发送 OPTIONS HTTP 请求时未提供适当的身份验证凭据,就会出现此错误。Elasticsearch 要求对所有类型的请求(包括 OPTIONS 请求)进行身份验证。要解决此问题,您可以在请求中提供有效的凭据,或者配置 Elasticsearch 允许未经身份验证的 OPTIONS 请求。此外,您还可以使用 API 密钥进行身份验证,或使用代理服务器在请求到达 Elasticsearch 之前处理 OPTIONS 请求。 日志上下文 # 日志"Cannot dispatch OPTIONS request; as they are not authenticated"的类名是 SecurityRestFilter.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: // 对于使用 OPTIONS 方法的 HTTP 请求,身份验证会被绕过;因此此健全性检查可防止调度未经身份验证的请求 if (request.method() == Method.OPTIONS) { handleException( request; channel; new ElasticsearchSecurityException("Cannot dispatch OPTIONS request; as they are not authenticated") ); return; } if (enabled == false) { " --- > **版本:** 8.9-8.9 简而言之,当向 Elasticsearch 发送 OPTIONS HTTP 请求时未提供适当的身份验证凭据,就会出现此错误。Elasticsearch 要求对所有类型的请求(包括 OPTIONS 请求)进行身份验证。要解决此问题,您可以在请求中提供有效的凭据,或者配置 Elasticsearch 允许未经身份验证的 OPTIONS 请求。此外,您还可以使用 API 密钥进行身份验证,或使用代理服务器在请求到达 Elasticsearch 之前处理 OPTIONS 请求。 ## 日志上下文 ----------- 日志"Cannot dispatch OPTIONS request; as they are not authenticated"的类名是 [SecurityRestFilter.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java // 对于使用 OPTIONS 方法的 HTTP 请求,身份验证会被绕过;因此此健全性检查可防止调度未经身份验证的请求 if (request.method() == Method.OPTIONS) { handleException( request; channel; new ElasticsearchSecurityException("Cannot dispatch OPTIONS request; as they are not authenticated") ); return; } if (enabled == false) { ```