fix: fix gemini stream output

This commit is contained in:
Hk-Gosuto
2023-12-29 14:10:51 +08:00
parent 9e86aa0901
commit 78bc819742
4 changed files with 40 additions and 17 deletions

View File

@@ -46,7 +46,7 @@ async function handle(
});
}
const bearToken = req.headers.get("Authorization") ?? "";
const bearToken = req.headers.get("x-goog-api-key") ?? "";
const token = bearToken.trim().replaceAll("Bearer ", "").trim();
const key = token ? token : serverConfig.googleApiKey;
@@ -63,7 +63,7 @@ async function handle(
);
}
const fetchUrl = `${baseUrl}/${path}?key=${key}&alt=sse`;
const fetchUrl = `${baseUrl}/${path}?key=${key}`;
const fetchOptions: RequestInit = {
headers: {
"Content-Type": "application/json",