diff --git a/composables/useGetCurrentDomain.ts b/composables/useGetCurrentDomain.ts index 2200105..fe80d01 100644 --- a/composables/useGetCurrentDomain.ts +++ b/composables/useGetCurrentDomain.ts @@ -3,17 +3,12 @@ export default function useGetCurrentDomain() { if (process.server) { const hostHeader = useRequestHeaders(); - currentDomain = hostHeader['x-forwarded-host'] || hostHeader.host; - - if ( - !currentDomain.startsWith('http://') || - !currentDomain.startsWith('https://') - ) { - currentDomain = 'https://' + currentDomain; - } + const rawDomain = hostHeader['x-forwarded-host'] || hostHeader.host || ''; + currentDomain = `https://${rawDomain}`; } else if (process.client) { - currentDomain = window.location.protocol + '//' + window.location.hostname; + const rawDomain = window.location.hostname; + currentDomain = `https://${rawDomain}`; } return currentDomain; -} +} \ No newline at end of file