From df365996e9e2f97fbc52527a25857941a7ef5e3c Mon Sep 17 00:00:00 2001 From: rongquan1 <85145303+rongquan1@users.noreply.github.com> Date: Fri, 31 Oct 2025 15:19:59 +0800 Subject: [PATCH 1/3] fix: update headers --- src/common/API/storageAPI.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/API/storageAPI.tsx b/src/common/API/storageAPI.tsx index eb868b25..6192afea 100644 --- a/src/common/API/storageAPI.tsx +++ b/src/common/API/storageAPI.tsx @@ -12,6 +12,7 @@ const fetchCsrfToken = async (documentStorage: DocumentStorage): Promise method: "get", url: url, withCredentials: true, + headers: getHeaders(), }); const csrfToken = response.data.csrfToken; @@ -52,7 +53,7 @@ export const getQueueNumber = async (documentStorage: DocumentStorage): Promise< return axios({ method: "get", url: url, - headers: getHeaders(documentStorage), + headers: getHeaders(), }); }; @@ -69,7 +70,7 @@ export const uploadToStorage = async ( return axios({ method: "post", url: uri, - headers: getHeaders(documentStorage, csrfToken), // Add CSRF token to headers + headers: getHeaders(csrfToken), // Add CSRF token to headers data: { document: doc.wrappedDocument, }, From 858e04ef80e4a8a26b2e9477053f031dfff92536 Mon Sep 17 00:00:00 2001 From: rongquan1 <85145303+rongquan1@users.noreply.github.com> Date: Fri, 31 Oct 2025 15:27:53 +0800 Subject: [PATCH 2/3] fix: update --- src/common/API/storageAPI.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/common/API/storageAPI.tsx b/src/common/API/storageAPI.tsx index 6192afea..e4fc1b17 100644 --- a/src/common/API/storageAPI.tsx +++ b/src/common/API/storageAPI.tsx @@ -26,19 +26,18 @@ const fetchCsrfToken = async (documentStorage: DocumentStorage): Promise } }; -const getHeaders = (documentStorage: DocumentStorage, csrfToken?: string): AxiosHeaders => { +const getHeaders = (csrfToken?: string): AxiosHeaders => { const headers = new AxiosHeaders({ "Content-Type": "application/json", }); const xApiKey = "x-api-key"; - if (documentStorage.apiKey) { - const apiKey = process.env.REACT_APP_API_KEY_DOCUMENT_STORAGE - ? process.env.REACT_APP_API_KEY_DOCUMENT_STORAGE - : documentStorage.apiKey; - headers.set(xApiKey, apiKey); - } + const apiKey = process.env.REACT_APP_API_KEY_DOCUMENT_STORAGE; + + if (!apiKey) throw new Error("API key not found"); + + headers.set(xApiKey, apiKey); if (csrfToken) { headers.set("X-CSRF-Token", csrfToken); // Set CSRF token if passed From 66231383ef1c542284c61f4172676c3baae520f0 Mon Sep 17 00:00:00 2001 From: rongquan1 <85145303+rongquan1@users.noreply.github.com> Date: Fri, 31 Oct 2025 15:32:07 +0800 Subject: [PATCH 3/3] fix: update --- src/common/API/storageAPI.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/API/storageAPI.tsx b/src/common/API/storageAPI.tsx index e4fc1b17..3a085b3f 100644 --- a/src/common/API/storageAPI.tsx +++ b/src/common/API/storageAPI.tsx @@ -36,7 +36,7 @@ const getHeaders = (csrfToken?: string): AxiosHeaders => { const apiKey = process.env.REACT_APP_API_KEY_DOCUMENT_STORAGE; if (!apiKey) throw new Error("API key not found"); - + headers.set(xApiKey, apiKey); if (csrfToken) {