From 73f701488783a86e3f66feb6198fe32b6f85551d Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Thu, 27 Jul 2023 18:38:07 +0200 Subject: [PATCH] Updated the RequestUtil.js --- client/src/common/utils/RequestUtil.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/common/utils/RequestUtil.js b/client/src/common/utils/RequestUtil.js index fd3bc5c..22d1a7c 100644 --- a/client/src/common/utils/RequestUtil.js +++ b/client/src/common/utils/RequestUtil.js @@ -1,8 +1,10 @@ -const URL = process.env.NODE_ENV === 'production' ? "https://tools-api.gnmyt.dev/" : "http://localhost:7182/"; +const DEFAULT_URL = process.env.NODE_ENV === 'production' ? "https://tools-api.gnmyt.dev/" : "http://localhost:7182/"; + +const getURL = () => localStorage.getItem("url") || DEFAULT_URL; // Run a plain request with all default values export const request = (path, method = "GET", body = {}, headers = {}) => { - return fetch(URL + path, {headers, method, body: method !== "GET" ? JSON.stringify(body) : undefined}); + return fetch(getURL() + path, {headers, method, body: method !== "GET" ? JSON.stringify(body) : undefined}); } // Run a GET request and get the json of the response