Fix worker not using the correct url

This commit is contained in:
Eric NGUYEN 2022-11-07 10:20:15 +01:00
parent 80b83dcec7
commit 704ae2e2d2

View file

@ -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]);