fix: prefix axios baseURL with import.meta.env.BASE_URL for sub-path routing

/api/v1 (absolute) was routing to menagerie.circuitforge.tech/api/v1 which
hit the global @api_no_session gate instead of the Magpie API at /magpie/api*.

Using import.meta.env.BASE_URL (set to /magpie/ at build time via VITE_BASE_URL)
produces /magpie/api/v1 in production and /api/v1 in dev (where Vite proxies /api).

Also adds vite-env.d.ts so TypeScript recognises import.meta.env.
This commit is contained in:
Alan Weinstock 2026-05-27 23:07:31 -07:00
parent c8cdfde066
commit 92799b05f9
2 changed files with 2 additions and 1 deletions

View file

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
const http = axios.create({ baseURL: '/api/v1' }) const http = axios.create({ baseURL: `${import.meta.env.BASE_URL}api/v1` })
// ------------------------------------------------------------------ // // ------------------------------------------------------------------ //
// Types // Types

1
frontend/src/vite-env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="vite/client" />