1
0
Fork 0
mirror of https://github.com/xHyroM/waki.git synced 2024-11-23 07:01:06 +01:00

fix: use api key search param instead of header

This commit is contained in:
Jozef Steinhübl 2024-07-17 17:41:38 +02:00
parent 1788e6d215
commit 9b0fd2b67b
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F

View file

@ -23,14 +23,17 @@ export default {
for (const provider of providers) { for (const provider of providers) {
const url = new URL(provider.url); const url = new URL(provider.url);
url.pathname += baseUrl.pathname; url.pathname += baseUrl.pathname;
url.searchParams.append("api_key", provider.token);
const headers = new Headers(request.headers);
headers.delete("Authorization");
if (body !== null) { if (body !== null) {
// @ts-expect-error expected // @ts-expect-error expected
res = await fetch(url.toString(), { res = await fetch(url.toString(), {
method: request.method, method: request.method,
headers: { headers: {
...request.headers, ...headers,
authorization: `Bearer ${btoa(provider.token)}`,
}, },
body: body(), body: body(),
}); });
@ -39,8 +42,7 @@ export default {
res = await fetch(url.toString(), { res = await fetch(url.toString(), {
method: request.method, method: request.method,
headers: { headers: {
...request.headers, ...headers,
authorization: `Bearer ${btoa(provider.token)}`,
}, },
}); });
} }