python service managment on client, port configuration

This commit is contained in:
michalcourson
2026-02-24 18:08:58 -05:00
parent d49ac95fa2
commit 47cdaa76b6
26 changed files with 244 additions and 67 deletions

View File

@ -1,13 +1,13 @@
const getBaseUrl = () => {
const getBaseUrl = async () => {
const port = await window.audio.getPort();
if (port.error || !port.port) {
return `http://localhost:5010`;
}
// You can store the base URL in localStorage, a config file, or state
return localStorage.getItem('baseUrl') || 'http://localhost:5010';
return `http://localhost:${port.port}`;
};
export function apiFetch(endpoint: string, options = {}) {
const url = `${getBaseUrl()}/${endpoint}`;
export default async function apiFetch(endpoint: string, options = {}) {
const url = `${await getBaseUrl()}/${endpoint}`;
return fetch(url, options);
}
export function setBaseUrl(baseUrl: string) {
localStorage.setItem('baseUrl', baseUrl);
}