From cf86ff57de4675c767bf5b443786f6e8c941eedf Mon Sep 17 00:00:00 2001 From: "Jeffrey I. Schiller" Date: Sun, 5 Jun 2022 15:45:43 -0400 Subject: [PATCH] Fix createURL The Javascript URL object takes a second argument which is the base to use for the URL. However it only accepts the "root" of the base. So arguments such as http://localhost/example get silently turned into http://localhost/ This change places the baseURL within the path element, after making sure that it ends with a slash (/). --- frontend/src/api/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index ddddcfa7..e5ee94ec 100644 --- a/frontend/src/api/utils.js +++ b/frontend/src/api/utils.js @@ -62,7 +62,11 @@ export function removePrefix(url) { } export function createURL(endpoint, params = {}, auth = true) { - const url = new URL(encodePath(endpoint), origin + baseURL); + let prefix = baseURL; + if (prefix[prefix.length] != '/') { + prefix = prefix + '/'; + } + const url = new URL(prefix + encodePath(endpoint), origin); const searchParams = { ...(auth && { auth: store.state.jwt }),