Skip to content

[finding] the legacy-host redirect compares the raw Host header, so any port on it skips the canonical redirect #226

Description

@hotlong

Observed while exercising the domain-redirect table for #205. Not fixed there — out of that card's file surface intent, and it is a separate decision.

What was measured

Against a production server built from 0c4351f + the #205 branch, next start:

request Host path result
www.objectos.app /docs/quickstart 308 to https://docs.objectos.ai/docs/quickstart
www.objectos.app:8080 /docs/quickstart 200 — no redirect, page served under the legacy host

Why

middleware.ts reads the Host header raw and compares it whole:

const host = request.headers.get('host');
if (host === LEGACY_HOST) {

The Host header carries authority, i.e. host[:port] — the port is present whenever it is not the scheme default. So www.objectos.app:8080 is simply not equal to www.objectos.app and falls through to locale negotiation, which serves the page under the legacy host instead of redirecting off it.

The asymmetry is what makes this worth recording rather than just noticing: the same block explicitly clears the port on the way out

target.port = '';

— so the port was considered on the target side and not on the source side. That reads like an oversight rather than a decision, but only the maintainer can say.

Severity, honestly

Low, and possibly zero in production. The site sits behind Cloudflare on 443, where browsers omit the default port and the Host header arrives bare, so the redirect works for every real visitor today. The unhandled shape is reachable only by a request to the legacy host on a non-standard port, which that host does not serve.

If it is worth closing

Compare the hostname rather than the authority — split on : and take the first field, or parse it. One line, and the existing six-case redirect table plus a seventh row for the ported host would cover it. If instead the exact-match is deliberate (only ever answer the legacy host on its real port), a comment saying so would keep the next reader from "fixing" it.

Filed unassigned for triage.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions