komga/next-ui/src/api/base.ts
2026-03-30 17:18:05 +08:00

16 lines
431 B
TypeScript

declare global {
interface Window {
resourceBaseUrl: string
}
}
const fullUrl =
import.meta.env.VITE_KOMGA_API_URL || window.location.origin + (window.resourceBaseUrl || '/')
const baseUrlSlash = !fullUrl.endsWith('/') ? `${fullUrl}/` : fullUrl
const baseUrlNoSlash = baseUrlSlash.endsWith('/') ? baseUrlSlash.slice(0, -1) : baseUrlSlash
export const ApiBaseUrl = {
slash: baseUrlSlash,
noSlash: baseUrlNoSlash,
}