Files
BetiX/resources/js/utils/api.ts
Dolo 0280278978
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
Initialer Laravel Commit für BetiX
2026-04-04 18:01:50 +02:00

17 lines
503 B
TypeScript

// src/utils/api.ts
import { ref } from 'vue';
// A reactive reference to hold the API URL.
// It's initialized with a default/fallback value.
export const apiUrl = ref('/api');
/**
* Sets the global API URL from a reliable source, like the main layout component.
* @param url The API base URL from Inertia props.
*/
export function initializeApiUrl(url: string | null | undefined) {
if (url && typeof url === 'string') {
apiUrl.value = url.replace(/\/$/, ''); // Remove trailing slash
}
}