Add custom URL support to vue frontend

This commit is contained in:
2025-08-20 22:50:38 +02:00
parent 864f0a5a45
commit 8c0f8c6b44
8 changed files with 281 additions and 22 deletions

View File

@@ -7,6 +7,14 @@
</div>
<form @submit.prevent="handleAuth" class="auth-form">
<BaseInput
v-model="serverUrl"
type="url"
label="Server URL (optional)"
:placeholder="defaultServerUrl"
:disabled="isLoading"
/>
<BaseInput
v-model="token"
type="password"
@@ -47,10 +55,14 @@ const toastStore = useToastStore()
const { playSound } = useAudio()
const token = ref('')
const serverUrl = ref('')
const error = ref('')
const isLoading = ref(false)
const tokenInput = ref()
// Get default server URL for placeholder
const defaultServerUrl = authStore.getDefaultServerUrl()
const handleAuth = async () => {
if (!token.value.trim()) return
@@ -58,18 +70,20 @@ const handleAuth = async () => {
error.value = ''
try {
const success = await authStore.authenticate(token.value.trim())
// Use custom server URL if provided, otherwise use default
const customUrl = serverUrl.value.trim() || undefined
const success = await authStore.authenticate(token.value.trim(), customUrl)
if (success) {
await playSound('login')
toastStore.success('Authentication successful!')
router.push('/')
} else {
error.value = 'Invalid authentication token'
error.value = 'Invalid authentication token or server URL'
tokenInput.value?.focus()
}
} catch (err) {
error.value = 'Authentication failed. Please try again.'
error.value = 'Authentication failed. Please check your token and server URL.'
console.error('Auth error:', err)
} finally {
isLoading.value = false

View File

@@ -158,10 +158,13 @@ const toastStore = useToastStore()
const { sendMessage: sendMessageOffline } = useOfflineSync()
const { playWater, playSent, playSound, speak, stopSpeaking, isSpeaking } = useAudio()
// Set up services - ensure token is properly set
// Set up services - ensure token and URL are properly set
if (authStore.token) {
apiService.setToken(authStore.token)
}
if (authStore.serverUrl) {
apiService.setBaseUrl(authStore.serverUrl)
}
// Refs
const messagesContainer = ref()