Skip to content

fix(docs): make the canonical-host redirect actually run - #636

Merged
rubenvdlinde merged 1 commit into
mainfrom
fix/docs-run-worker-first
Aug 29, 2026
Merged

fix(docs): make the canonical-host redirect actually run#636
rubenvdlinde merged 1 commit into
mainfrom
fix/docs-run-worker-first

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

The redirect from #635 never fired

The asset server answers before the Worker script. When a request path matches a file in ./build, Cloudflare serves it directly and the script is never invoked — so the redirect could only run for paths with no asset, which is never the case for a real documentation page.

Why the green run was not evidence

Measured on the buildiq pilot. Every signal that normally counts said it worked:

  • the generated wrangler.toml carried main = "./docs-redirect-worker.js" and binding = "ASSETS"
  • wrangler printed env.ASSETS Assets, Uploaded openbuild-docs, Deployed openbuild-docs triggers
  • the workflow run was green

and openbuild.conduction.nl/docs/intro/ still answered 200, not 301.

What settled it was testing the worker's own workers.dev URL:

openbuild-docs.conduction-a2d.workers.dev/docs/intro/  ->  200

That hostname is not the canonical one either, so a running script would have redirected it too. The route was correct and the script was deployed — it simply never executed.

The fix

run_worker_first = true in [assets] puts the script ahead of the asset server. It is emitted only alongside canonical-host, so a site that has not opted in still gets byte-for-byte the config it had.

Verification

The generator was executed both ways again:

without canonical-host with it
output unchanged from before #635 gains main, binding, run_worker_first

Next: redeploy buildiq and confirm openbuild.conduction.nl 301s to buildiq.conduction.nl with the path preserved, before the remaining 20 apps go anywhere near this.

#635 added the canonical-host redirect and it never fired. The asset server
answers before the Worker: when the request path matches a file in ./build it
is served directly and the script is not invoked, so the redirect could only
run for paths with NO asset -- which is never, for a real documentation page.

Measured on the buildiq pilot. Everything that usually counts as evidence said
it worked: the generated wrangler.toml carried `main` and
`binding = "ASSETS"`, wrangler printed `env.ASSETS  Assets`, "Uploaded
openbuild-docs" and "Deployed openbuild-docs triggers", and the run was green.
openbuild.conduction.nl still answered 200 instead of 301.

What settled it was the worker's OWN workers.dev URL also answering 200. That
hostname is not the canonical one either, so a running script would have
redirected it; the route was fine, the script simply never executed.

`run_worker_first = true` puts the script in front of the asset server. It is
emitted only alongside canonical-host, so a site that has not opted in still
gets byte-for-byte the config it had.
@rubenvdlinde
rubenvdlinde merged commit 0137121 into main Aug 29, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant