From 704ae2e2d2ed1bdcf226a89f8c83644f57ae600e Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Mon, 7 Nov 2022 10:20:15 +0100 Subject: [PATCH] Fix worker not using the correct url --- src/Components/UI/UseWorker.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Components/UI/UseWorker.tsx b/src/Components/UI/UseWorker.tsx index c231f07..7569bc3 100644 --- a/src/Components/UI/UseWorker.tsx +++ b/src/Components/UI/UseWorker.tsx @@ -16,7 +16,7 @@ export function UseWorker( // use webworker for the stringify to avoid freezing myWorker.postMessage({ state, - url: import.meta.env.VITE_API_GET_FEEDBACK_URL + url: configurationUrl ?? import.meta.env.VITE_API_GET_FEEDBACK_URL }); return () => { @@ -39,7 +39,8 @@ export function UseAsync( ApplicationState: state }; const dataParsed = JSON.stringify(request, GetCircularReplacer()); - fetch(import.meta.env.VITE_API_GET_FEEDBACK_URL, { + const url = configurationUrl ?? import.meta.env.VITE_API_GET_FEEDBACK_URL; + fetch(url, { method: 'POST', headers: new Headers({ // eslint-disable-next-line @typescript-eslint/naming-convention @@ -47,9 +48,9 @@ export function UseAsync( }), body: dataParsed }) - .then(async (response) => await response.json() + .then(async(response) => await response.json() ) - .then(async (json: IGetFeedbackResponse) => { + .then(async(json: IGetFeedbackResponse) => { setMessages(json.messages); }); }, [state]);