Files
umed/web/composables/useSiteUrl.ts
T
2026-07-09 14:35:32 +08:00

14 lines
451 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { resolveSiteUrl } from '~/utils/seo'
/** 根据当前访问域名解析站点 URL(umedglobal.cn / umedglobal.com.cn / umedglobal.com 等多域名共用) */
export function useSiteUrl() {
const config = useRuntimeConfig()
const fallback = String(config.public.siteUrl)
const requestURL = useRequestURL({
xForwardedHost: true,
xForwardedProto: true
})
return computed(() => resolveSiteUrl(fallback, requestURL.origin))
}