based path correction

This commit is contained in:
2026-01-21 20:48:45 +00:00
parent 3eeaa797ad
commit 4338f347c5
5 changed files with 10 additions and 12 deletions

View File

@@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import { ui_colors_dropdown } from '~/utils/set_colors';
const loggedIn = ref(false); const loggedIn = ref(false);
const logout_prompt = ref(false); const logout_prompt = ref(false);
@@ -28,7 +27,7 @@ const props = defineProps({
function logout() { function logout() {
return $fetch("/logout").then((r) => { return $fetch("/logout").then((r) => {
reloadNuxtApp({ path: "/" }) reloadNuxtApp({ path: useBasedPath("/") })
}); });
} }

View File

@@ -50,7 +50,7 @@
}).then(r => { // r resolves to { file: "my_audio.mp3" } }).then(r => { // r resolves to { file: "my_audio.mp3" }
const file = r.file; // in this case r["file"] --> "my_audio.mp3" const file = r.file; // in this case r["file"] --> "my_audio.mp3"
const a = document.createElement("a"); const a = document.createElement("a");
a.href = urlJoin(conf.app.baseURL, `/download/${file}`) a.href = useBasedPath(`/download/${file}`)
a.download = file; // sets suggested filename a.download = file; // sets suggested filename
file_dwnl.value = a.href; // this ref activates the Download button file_dwnl.value = a.href; // this ref activates the Download button
document.body.appendChild(a); // must append first document.body.appendChild(a); // must append first
@@ -62,7 +62,7 @@
const res = r.data; const res = r.data;
console.log(r.data) console.log(r.data)
if(res.statusCode == 401) { if(res.statusCode == 401) {
reloadNuxtApp({path: "/login"}) navigateTo(useBasedPath("/login"),{external: true})
} }
else toast.add({ else toast.add({
title: "Error", title: "Error",

View File

@@ -1,12 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import * as z from 'zod' import * as z from 'zod'
import type { FormSubmitEvent, AuthFormField } from '@nuxt/ui' import type { FormSubmitEvent, AuthFormField } from '@nuxt/ui'
import urlJoin from 'url-join'
const toast = useToast() const toast = useToast()
const config = useRuntimeConfig() const config = useRuntimeConfig()
const base_url = config.app.baseURL.endsWith('/') ? config.app.baseURL.slice(0, -1) : config.app.baseURL
const wrong_login = ref(false) const wrong_login = ref(false)
const fields: AuthFormField[] = [{ const fields: AuthFormField[] = [{
@@ -47,7 +46,7 @@ function onSubmit(payload: FormSubmitEvent<Schema>) {
remember: payload.data.remember || false remember: payload.data.remember || false
} }
}).then((r) => { }).then((r) => {
reloadNuxtApp({path: "/"}); navigateTo(useBasedPath("/"), { external: true})
}).catch((err) => { }).catch((err) => {
if(err.data.statusCode == 401) { if(err.data.statusCode == 401) {
wrong_login.value = true; wrong_login.value = true;

View File

@@ -2,6 +2,7 @@
import * as z from 'zod' import * as z from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui' import type { FormSubmitEvent } from '@nuxt/ui'
import urlJoin from "url-join" import urlJoin from "url-join"
import { use_based_path } from '~/composables/based_path'
definePageMeta({ definePageMeta({
layout: "settings", layout: "settings",
@@ -28,7 +29,7 @@
async function submitChanges(event: FormSubmitEvent<Schema>) { async function submitChanges(event: FormSubmitEvent<Schema>) {
loading_btn.value = true loading_btn.value = true
await fetch(urlJoin(conf.app.baseURL, "/settings/edit_user"), { await fetch(use_based_path("/settings/edit_user"), {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -66,7 +67,7 @@
<div class="gap-3 justify-between"> <div class="gap-3 justify-between">
<div class="flex-1 w-full gap-2 mt-5 mb-5"> <div class="flex-1 w-full gap-2 mt-5 mb-5">
<UFormField label="First Name" orientation="horizontal" name="first_name"> <UFormField label="First Name" orientation="horizontal" name="first_name">
<UInput v-if="user_data" v-model="user_data.first_name"/> <UInput v-if="user_data" v-model="user_data.first_name" required/>
<USkeleton v-else class="w-53 h-7" /> <USkeleton v-else class="w-53 h-7" />
</UFormField> </UFormField>
</div> </div>

View File

@@ -5,7 +5,6 @@
definePageMeta({ definePageMeta({
layout: "settings", layout: "settings",
middleware: ["login-required"]
}) })
const loading_btn = ref(false) const loading_btn = ref(false)
const toast = useToast() const toast = useToast()
@@ -35,7 +34,7 @@
async function submitChanges(event: FormSubmitEvent<Schema>) { async function submitChanges(event: FormSubmitEvent<Schema>) {
loading_btn.value = true loading_btn.value = true
try { try {
fetch(urlJoin(config.app.baseURL,"/settings/changepw"), { fetch(useBasedPath("/settings/changepw"), {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"