Files
order_site/apps/frontend/src/utils/site.ts
T

23 lines
620 B
TypeScript

const DEFAULT_WORKER_SITE_URL = 'https://worker.khhao.com'
export const WORKER_SITE_ORIGIN = resolveWorkerSiteOrigin()
export function isWorkerSite() {
const configuredHostname = new URL(WORKER_SITE_ORIGIN).hostname
return (
window.location.hostname === configuredHostname ||
(import.meta.env.DEV && window.location.hostname === 'worker.localhost')
)
}
function resolveWorkerSiteOrigin() {
const configuredUrl = String(import.meta.env.VITE_WORKER_SITE_URL || '').trim()
try {
return new URL(configuredUrl || DEFAULT_WORKER_SITE_URL).origin
} catch {
return DEFAULT_WORKER_SITE_URL
}
}