Merge branch 'main' into Training-Report

This commit is contained in:
2025-11-22 13:08:30 -05:00
5 changed files with 41 additions and 16 deletions

2
ui/.env.example Normal file
View File

@@ -0,0 +1,2 @@
# SITE SETTINGS
BASE_URL=

View File

@@ -24,9 +24,10 @@ const userStore = useUserStore();
// console.log(data);
// userStore.user = data;
// });
const APIHOST = import.meta.env.VITE_APIHOST;
async function logout() {
await fetch(`${import.meta.env.VITE_APIHOST}/logout`, {
await fetch(`${APIHOST}/logout`, {
method: 'POST',
credentials: 'include',
});
@@ -112,7 +113,7 @@ function formatDate(dateStr) {
</DropdownMenuContent>
</DropdownMenu>
<a v-else href="https://aj17thdevapi.nexuszone.net/login">Login</a>
<a v-else :href="APIHOST+'/login'">Login</a>
</div>
</div>
<Separator></Separator>

View File

@@ -40,6 +40,9 @@ const router = createRouter({
]
})
const addr = import.meta.env.VITE_APIHOST;
router.beforeEach(async (to) => {
const user = useUserStore()
@@ -48,13 +51,13 @@ router.beforeEach(async (to) => {
await user.loadUser();
}
// // Not logged in
// if (to.meta.requiresAuth && !user.isLoggedIn) {
// // Redirect back to original page after login
// const redirectUrl = encodeURIComponent(window.location.origin + to.fullPath)
// window.location.href = `https://aj17thdevapi.nexuszone.net/login?redirect=${redirectUrl}`
// return false // Prevent Vue Router from continuing
// }
// Not logged in
if (to.meta.requiresAuth && !user.isLoggedIn) {
// Redirect back to original page after login
const redirectUrl = encodeURIComponent(window.location.origin + to.fullPath)
window.location.href = `${addr}/login?redirect=${redirectUrl}`
return false // Prevent Vue Router from continuing
}
// // Must be a member