Skip to content

Commit

Permalink
better api url sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Jun 19, 2024
1 parent f58a0b7 commit fed1a4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# make sure that there's no trailing slash
VITE_API_URL=https://api.faithfulpack.net/v2

# You need to set FallbackResource to dist/index.html if you're using Apache (blame Vue routing)
PORT=7000
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,18 @@ ALL_TABS.filter((t) => t.roles === undefined)
router.addRoute(missingRoute);

window.apiURL = import.meta.env.VITE_API_URL;
// fix trailing slash
if (apiURL.endsWith("/")) window.apiURL = window.apiURL.slice(0, -1);

// set as global
window.settings = await axios.get(`${window.apiURL}/settings/raw`).then((res) => res.data);
window.settings = await axios
.get(`${window.apiURL}/settings/raw`)
.then((res) => res.data)
.catch((err) => {
console.error(err);
// don't completely break the webapp if settings can't be fetched
return {};
});

const pinia = createPinia();
Vue.use(pinia);
Expand Down
2 changes: 1 addition & 1 deletion resources/strings/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export default {
},
slug: {
label: "Add-on slug",
hint: "Changing this will break old links!"
hint: "Changing this will break old links!",
},
reason: {
title: "Update reason",
Expand Down

0 comments on commit fed1a4e

Please sign in to comment.