From f653f32289730ddb1cade74ba3a14a090074065e Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 13 Jul 2023 04:11:19 +0800 Subject: [PATCH 1/4] U event/axios.js: fix gitlab baseURL for site at sub dir --- event/axios.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/event/axios.js b/event/axios.js index 07ca014..913fe0a 100644 --- a/event/axios.js +++ b/event/axios.js @@ -1,7 +1,10 @@ import axios from "axios"; +const base_url = window.location.origin + (document.head.innerHTML.match(/;gon.relative_url_root="(\/\w+?)";/) || [,''])[1]; +console.log('---spantree:', base_url); + const options = { - baseURL: `${window.location.origin}/api/v4/projects/`, + baseURL: `${base_url}/api/v4/projects/`, }; const inst = axios.create(options); From 0d44dfe5d494c261164196c2af04b1ea6bcbfe09 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 17 Jul 2023 22:16:32 +0800 Subject: [PATCH 2/4] U event/axios.js: comment out debug log --- event/axios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/axios.js b/event/axios.js index 913fe0a..69a55b3 100644 --- a/event/axios.js +++ b/event/axios.js @@ -1,7 +1,7 @@ import axios from "axios"; const base_url = window.location.origin + (document.head.innerHTML.match(/;gon.relative_url_root="(\/\w+?)";/) || [,''])[1]; -console.log('---spantree:', base_url); +// console.log('---spantree:', base_url); const options = { baseURL: `${base_url}/api/v4/projects/`, From c3c8d95f6f19b9747cc0f8756949d4282b0e3c09 Mon Sep 17 00:00:00 2001 From: chen Date: Wed, 26 Jul 2023 04:34:53 +0800 Subject: [PATCH 3/4] U event/axios.js: format code, improve code by ?. ?? --- event/axios.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/event/axios.js b/event/axios.js index 69a55b3..9d5e91c 100644 --- a/event/axios.js +++ b/event/axios.js @@ -1,6 +1,9 @@ import axios from "axios"; -const base_url = window.location.origin + (document.head.innerHTML.match(/;gon.relative_url_root="(\/\w+?)";/) || [,''])[1]; +const base_url = window.location.origin + ( + document.head.innerHTML.match(/;gon.relative_url_root="(\/\w+?)";/)?.[1] + ?? '' +); // console.log('---spantree:', base_url); const options = { From cde3add9b9be59ba1ff033c1ad8ae94157d7d324 Mon Sep 17 00:00:00 2001 From: chen Date: Wed, 26 Jul 2023 04:44:37 +0800 Subject: [PATCH 4/4] U event/axios.js: rename var --- event/axios.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/event/axios.js b/event/axios.js index 9d5e91c..402d9a8 100644 --- a/event/axios.js +++ b/event/axios.js @@ -1,13 +1,13 @@ import axios from "axios"; -const base_url = window.location.origin + ( +const siteURL = window.location.origin + ( document.head.innerHTML.match(/;gon.relative_url_root="(\/\w+?)";/)?.[1] ?? '' ); -// console.log('---spantree:', base_url); +// console.log('---spantree:', siteURL); const options = { - baseURL: `${base_url}/api/v4/projects/`, + baseURL: `${siteURL}/api/v4/projects/`, }; const inst = axios.create(options);