From b13e048b3d75779e7287da2d68fe37096a7da474 Mon Sep 17 00:00:00 2001 From: tutaru99 Date: Tue, 3 Dec 2024 14:21:11 +0100 Subject: [PATCH 1/3] debugging composable --- utils/seoCanonicalUrlHandler.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/seoCanonicalUrlHandler.ts b/utils/seoCanonicalUrlHandler.ts index ac46352..eaeda46 100644 --- a/utils/seoCanonicalUrlHandler.ts +++ b/utils/seoCanonicalUrlHandler.ts @@ -6,6 +6,7 @@ export const seoCanonicalUrlHandler = (url: string, isFrontPage: boolean) => { } const currentDomain = useGetCurrentDomain(); + console.log('currentDomain from the composable', currentDomain); if (isFrontPage) { return currentDomain; From cbe5ec5cb5ac079a9ab018096ddb7579862c70c7 Mon Sep 17 00:00:00 2001 From: tutaru99 Date: Tue, 3 Dec 2024 14:43:48 +0100 Subject: [PATCH 2/3] Seo canonical fix --- composables/useGetCurrentDomain.ts | 13 ++++--------- utils/seoCanonicalUrlHandler.ts | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/composables/useGetCurrentDomain.ts b/composables/useGetCurrentDomain.ts index 6c1d7f3..36c255a 100644 --- a/composables/useGetCurrentDomain.ts +++ b/composables/useGetCurrentDomain.ts @@ -3,16 +3,11 @@ 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.hostname; + const rawDomain = window.location.hostname; + currentDomain = `https://${rawDomain}`; } return currentDomain; diff --git a/utils/seoCanonicalUrlHandler.ts b/utils/seoCanonicalUrlHandler.ts index eaeda46..9b1d8dc 100644 --- a/utils/seoCanonicalUrlHandler.ts +++ b/utils/seoCanonicalUrlHandler.ts @@ -6,7 +6,7 @@ export const seoCanonicalUrlHandler = (url: string, isFrontPage: boolean) => { } const currentDomain = useGetCurrentDomain(); - console.log('currentDomain from the composable', currentDomain); + console.log('seoCanonicalUrlHandler from the composable:', currentDomain); if (isFrontPage) { return currentDomain; From b68a5e70a32e0edd70f590874446423faf0790e6 Mon Sep 17 00:00:00 2001 From: tutaru99 Date: Tue, 3 Dec 2024 15:04:27 +0100 Subject: [PATCH 3/3] removd debugging --- utils/seoCanonicalUrlHandler.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/seoCanonicalUrlHandler.ts b/utils/seoCanonicalUrlHandler.ts index 44f610b..ac46352 100644 --- a/utils/seoCanonicalUrlHandler.ts +++ b/utils/seoCanonicalUrlHandler.ts @@ -6,8 +6,6 @@ export const seoCanonicalUrlHandler = (url: string, isFrontPage: boolean) => { } const currentDomain = useGetCurrentDomain(); - console.log('seoCanonicalUrlHandler from the composable:', currentDomain); - if (isFrontPage) { return currentDomain;