chore(server): support elasticsearch apiKey (#12405)

This commit is contained in:
fengmk2
2025-05-21 08:35:51 +00:00
parent ff15779208
commit abfc994180
12 changed files with 36 additions and 29 deletions

View File

@@ -248,7 +248,9 @@ export class ElasticsearchProvider extends SearchProvider {
const headers = {
'Content-Type': contentType,
} as Record<string, string>;
if (this.config.provider.password) {
if (this.config.provider.apiKey) {
headers.Authorization = `ApiKey ${this.config.provider.apiKey}`;
} else if (this.config.provider.password) {
headers.Authorization = `Basic ${Buffer.from(`${this.config.provider.username}:${this.config.provider.password}`).toString('base64')}`;
}
const response = await fetch(url, {