30 lines
1.4 KiB
TypeScript
30 lines
1.4 KiB
TypeScript
/**
|
|
* Purpose: normalizeBaseUrl supports api.ts by holding or executing the normalize base url page or API role.
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
function normalizeBaseUrl(value: string | undefined, fallbackValue: string) {
|
|
const target = String(value || fallbackValue).trim()
|
|
return target.replace(/\/+$/, '')
|
|
}
|
|
|
|
/**
|
|
* Purpose: DEFAULT_API_BASE_URL supports api.ts by holding or executing the default api base url page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const DEFAULT_API_BASE_URL = import.meta.env.DEV ? '/api' : 'https://yunail.art/api'
|
|
|
|
/**
|
|
* Purpose: API_CONFIG supports api.ts by holding or executing the api config page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
export const API_CONFIG = {
|
|
mode: import.meta.env.MODE,
|
|
apiBaseUrl: normalizeBaseUrl(import.meta.env.VITE_API_BASE_URL, DEFAULT_API_BASE_URL),
|
|
}
|
|
|
|
/**
|
|
* Purpose: API_BASE_URL supports api.ts by holding or executing the api base url page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
export const API_BASE_URL = API_CONFIG.apiBaseUrl
|