mirror of
https://github.com/xHyroM/waki.git
synced 2024-11-23 15:11:05 +01:00
fix: use api key search param instead of header
This commit is contained in:
parent
1788e6d215
commit
9b0fd2b67b
1 changed files with 6 additions and 4 deletions
10
src/index.ts
10
src/index.ts
|
@ -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)}`,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue