fix: prefix /api/session and /api/preferences with VITE_API_BASE
Some checks are pending
CI / Frontend typecheck + tests (push) Waiting to run
CI / Python tests (push) Waiting to run
Mirror / mirror (push) Waiting to run
Release / release (push) Waiting to run

Both stores hardcoded /api/* paths without reading VITE_API_BASE, causing
/api/session to hit the menagerie root (no /snipe prefix) and receive a
302 redirect to circuitforge.tech/login instead of a session response.
Every other store already read VITE_API_BASE correctly.
This commit is contained in:
pyr0ball 2026-04-16 12:51:39 -07:00
parent e428c1446e
commit 8e40e51ed3
2 changed files with 6 additions and 3 deletions

View file

@ -11,6 +11,8 @@ export interface UserPreferences {
}
}
const apiBase = (import.meta.env.VITE_API_BASE as string) ?? ''
export const usePreferencesStore = defineStore('preferences', () => {
const session = useSessionStore()
const prefs = ref<UserPreferences>({})
@ -25,7 +27,7 @@ export const usePreferencesStore = defineStore('preferences', () => {
loading.value = true
error.value = null
try {
const res = await fetch('/api/preferences')
const res = await fetch(`${apiBase}/api/preferences`)
if (res.ok) {
prefs.value = await res.json()
}
@ -40,7 +42,7 @@ export const usePreferencesStore = defineStore('preferences', () => {
if (!session.isLoggedIn) return
error.value = null
try {
const res = await fetch('/api/preferences', {
const res = await fetch(`${apiBase}/api/preferences`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ path, value }),

View file

@ -42,8 +42,9 @@ export const useSessionStore = defineStore('session', () => {
const isLoggedIn = computed(() => isCloud.value && userId.value !== 'anonymous' && !isGuest.value)
async function bootstrap() {
const apiBase = (import.meta.env.VITE_API_BASE as string) ?? ''
try {
const res = await fetch('/api/session')
const res = await fetch(`${apiBase}/api/session`)
if (!res.ok) return // local-mode with no session endpoint — keep defaults
const data = await res.json()
userId.value = data.user_id