Skip to content

Commit

Permalink
Remove VITE_BASE_URL
Browse files Browse the repository at this point in the history
Use window.location.origin to decide where to route API requests. VITE_BASE_URL added more complexity with little benefit
  • Loading branch information
daw1012345 committed Dec 26, 2024
1 parent 14322ec commit be9b3b9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 9 deletions.
1 change: 0 additions & 1 deletion .env.template

This file was deleted.

1 change: 0 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
7 changes: 1 addition & 6 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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';
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/ExfilledFilesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit be9b3b9

Please sign in to comment.