python service managment on client, port configuration
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user