From 19e5d28cf7155637b125d49306c4af1374eef6bd Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 2 Oct 2023 16:43:48 +0900 Subject: [PATCH] fix: properly implement "With credential" in the API console --- packages/client/src/os.ts | 3 ++- packages/client/src/pages/api-console.vue | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index 0e74ff741b..7a78e95530 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -24,6 +24,7 @@ export const api = (( endpoint: string, data: Record = {}, token?: string | null | undefined, + useToken: boolean = true, ) => { pendingApiRequestsCount.value++; @@ -42,7 +43,7 @@ export const api = (( body: JSON.stringify(data), credentials: "omit", cache: "no-cache", - headers: authorization ? { authorization } : {}, + headers: authorization && useToken ? { authorization } : {}, }) .then(async (res) => { const body = res.status === 204 ? null : await res.json(); diff --git a/packages/client/src/pages/api-console.vue b/packages/client/src/pages/api-console.vue index b7a533c450..80d9a4d03a 100644 --- a/packages/client/src/pages/api-console.vue +++ b/packages/client/src/pages/api-console.vue @@ -71,7 +71,8 @@ function send() { os.api( endpoint.value as keyof Endpoints, requestBody, - requestBody.i || (withCredential.value ? undefined : null), + null, + withCredential.value, ).then( (resp) => { sending.value = false;