server: avoid overwriting Authorization header (#10878)

* server: avoid overwriting Authorization header

If no API key is set, leave the Authorization header as is. It may be
used by another part of the Web stack, such as an authenticating proxy.

Fixes https://github.com/ggerganov/llama.cpp/issues/10854

* rebuild

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
This commit is contained in:
Gaetan BissonandXuan Son Nguyen authored and GitHub committed 2024-12-18 15:00:07 +01:00
1 parent 152610eda9
commit 7bbb5acf12
2 files changed
+1 -1

No files matched your search

Binary file not shown.
+1 -1
View File
@@ -445,7 +445,7 @@ const mainApp = createApp({
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': this.config.apiKey ? `Bearer ${this.config.apiKey}` : undefined,
...(this.config.apiKey ? {'Authorization': `Bearer ${this.config.apiKey}`} : {})
},
body: JSON.stringify(params),
signal: abortController.signal,