From be9b3b9b5d1ac7395a5e6f8d5e2418c92c4f9c19 Mon Sep 17 00:00:00 2001 From: daw1012345 Date: Thu, 26 Dec 2024 18:22:23 +0100 Subject: [PATCH] Remove VITE_BASE_URL Use window.location.origin to decide where to route API requests. VITE_BASE_URL added more complexity with little benefit --- .env.template | 1 - src/main.js | 1 - src/router.js | 7 +------ src/views/ExfilledFilesView.vue | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 .env.template diff --git a/.env.template b/.env.template deleted file mode 100644 index c48e350..0000000 --- a/.env.template +++ /dev/null @@ -1 +0,0 @@ -VITE_CALDERA_URL=http://localhost:8888 diff --git a/src/main.js b/src/main.js index b72985b..81bd253 100644 --- a/src/main.js +++ b/src/main.js @@ -17,7 +17,6 @@ const app = createApp(App); const $api = axios.create({ withCredentials: true, }); -if (import.meta.env.DEV) $api.defaults.baseURL = "http://localhost:8888"; app.provide("$api", $api); app.use(createPinia()); diff --git a/src/router.js b/src/router.js index b974b3b..bdb9af3 100644 --- a/src/router.js +++ b/src/router.js @@ -23,7 +23,7 @@ import NotFoundView from "./views/NotFoundView.vue"; // Cant use global API variable because we aren't in a component const $api = axios.create({ withCredentials: true, - baseURL: import.meta.env.VITE_CALDERA_URL || "http://localhost:8888", + baseURL: window.location.origin, }); const router = createRouter({ @@ -113,11 +113,6 @@ const router = createRouter({ { path: '/docs/index.html', beforeEnter: () => { - // Redirect to the external docs page - if (!import.meta.env.PROD) { - window.location.href = (import.meta.env.VITE_CALDERA_URL || 'http://localhost:8888') + '/docs/index.html'; - return; - } window.location.href = '/docs/index.html'; } }, diff --git a/src/views/ExfilledFilesView.vue b/src/views/ExfilledFilesView.vue index 37d8a6f..8892ab1 100644 --- a/src/views/ExfilledFilesView.vue +++ b/src/views/ExfilledFilesView.vue @@ -48,7 +48,7 @@ function downloadSelectedFiles() { let filename = filePath.split(/[\/\\]/); filename = filename[filename.length - 1]; let uri = `${ - import.meta.env.VITE_CALDERA_URL || "http://localhost:8888" + window.location.origin }/file/download_exfil?file=${btoa(filePath)}`; let downloadAnchorNode = document.createElement("a"); downloadAnchorNode.setAttribute("href", uri);