Skip to content

Commit

Permalink
Canonical tags fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
tutaru99 committed Dec 3, 2024
1 parent b13e048 commit 928ec90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions composables/useGetCurrentDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion utils/seoCanonicalUrlHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 928ec90

Please sign in to comment.