Skip to content

fix(language-selector): ignore the origin when checking the canonical URL - #2282

Merged
markdumay merged 2 commits into
mainfrom
fix/canonical-redirect-origin
Oct 28, 2026
Merged

markdumay merged 2 commits into
mainfrom
fix/canonical-redirect-origin

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

Problem

Regular pages emit an absolute self-referencing canonical (8ef21bb), and the language selector redirects whenever origin or pathname differ from it (7d04391). Any regular page served from a host other than the baseURL is therefore bounced to the baseURL host.

Observed in the CloudCannon visual editor: pages load from a *.proxy.cloudcannon.com origin, the script redirects the preview iframe away, and the editor hangs on "Initializing editor..." without any console error. Section pages (no canonical) were unaffected. Deploy previews on another host are affected the same way.

Change

Compare the pathname only. The guard exists for alias pages, whose pathname differs from the canonical, so those still redirect. Query string and hash handling (7d04391) and the case-insensitive comparison (904763f) are unchanged.

Verification

Bundled languageSelector.js with esbuild (@params stubbed, selector enabled) and ran it in jsdom, against main (control) and this branch:

Case main this PR
Other host, same path redirected stayed
Same host, ?utm_source=x#a stayed stayed
Same host, different case stayed stayed
Alias page redirected redirected

Also validated downstream on squadra.nl's CloudCannon site with an equivalent override: the visual editor initializes again. npm run lint:scripts passes.

🤖 Generated with Claude Code

… URL

Since 8ef21bb regular pages carry an absolute self-referencing canonical,
and since 7d04391 the canonical guard compares origin and pathname. Together
they redirect any regular page served from a host other than the baseURL to
the baseURL host. This breaks hosts that legitimately serve the same build,
such as the CloudCannon visual editor (pages load from a
*.proxy.cloudcannon.com origin and are bounced before the editor can
initialize) and deploy previews.

Compare the pathname only. The guard exists for alias pages, whose pathname
differs from the canonical one, so they keep redirecting. The query string
and hash handling (7d04391) and the case-insensitive comparison (904763f)
are unchanged. Before 8ef21bb regular pages had no canonical and never
redirected across hosts, so this restores that behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit 478bca0
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6ae1e071c92fe409e0558218
😎 Deploy Preview https://deploy-preview-2282--gethinode-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@markdumay
markdumay enabled auto-merge October 28, 2026 11:47
@markdumay
markdumay merged commit 64aa946 into main Oct 28, 2026
17 checks passed
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.45.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@markdumay
markdumay deleted the fix/canonical-redirect-origin branch October 28, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant