fix(docs): compare hostname, not authority, in legacy-host redirect - #228
Merged
Conversation
The Host header carries `host[:port]`, so a request to the legacy host on a non-default port (e.g. `www.objectos.app:8080`) was not `===` LEGACY_HOST, fell through to locale negotiation, and served the page (200) under the legacy host instead of redirecting (308) off it. The same block already strips the port from the target (`target.port = ''`), so the port was accounted for on the way out and not on the way in. Comparing the hostname on both sides closes that gap without changing the target normalisation. Fixes #226
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #226
The change
middleware.ts's legacy-host redirect compared the rawHostheader(
host[:port], the authority) against a bare hostname literal, sowww.objectos.app:8080was never===LEGACY_HOSTand fell through tolocale negotiation — served (200) under the legacy host instead of
redirected (308) off it. Three lines below, the same block already strips
the port from the target (
target.port = ''), so the port was accountedfor on the way out and not on the way in.
Fix: compare the hostname (
host?.split(':')[0]), not the authority, oneline. No change to the target-side normalisation.
Verification
next build+next start, curl with an explicitHostheader, PID killedby explicit PID after each run (never
pkill -f). The redirect tablereused from #204 / #223 / #225 / #227, plus the new row this card adds:
www.objectos.app/docs/quickstarthttps://docs.objectos.ai/docs/quickstartwww.objectos.app/docs/quickstart?utm=x&ref=ydocs.objectos.ai/docs/quickstartdocs.objectos.ai/zh-Hant/docs/quickstartdocs.objectos.ai/zh-hant/docs/quickstart/zh-Hant/docs/quickstartwww.objectos.app/cn/docs/quickstarthttps://docs.objectos.ai/cn/docs/quickstart(domain rule wins;/cn/handled next hop)www.objectos.app:8080/docs/quickstarthttps://docs.objectos.ai/docs/quickstart, no port on targetdocs.objectos.ai:3000/docs/quickstartLEGACY_HOSTspecifically, not "strip the port from every Host and compare," which would have wrongly caught this row too#225's controls, re-checked on this tree:
/en/docs/quickstart→ 307(default-locale strip). Matches expectations.
Row 7's "before" was reproduced empirically, not inferred: the pre-fix file
was rebuilt and started on its own port and returned 200 for the ported
legacy host, confirming the bug before restoring the fix and rebuilding
again for the final table above.
Gates, all fresh (
--force, no turbo cache reuse), exit codes capturedbefore any pipe:
No
.changeset/entry — this repo has no changeset tooling (confirmed: no.changeset/directory, no changeset references in anypackage.jsonorCI workflow); the site is a private, unpublished app.
File surface:
apps/docs/middleware.tsonly, as scoped —git diff --statconfirms.
Generated by Claude Code