fix(docs): make the canonical-host redirect actually run - #636
Merged
Conversation
#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.
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.
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:
wrangler.tomlcarriedmain = "./docs-redirect-worker.js"andbinding = "ASSETS"env.ASSETS Assets,Uploaded openbuild-docs,Deployed openbuild-docs triggersand
openbuild.conduction.nl/docs/intro/still answered 200, not 301.What settled it was testing the worker's own
workers.devURL: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 = truein[assets]puts the script ahead of the asset server. It is emitted only alongsidecanonical-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:
canonical-hostmain,binding,run_worker_firstNext: redeploy buildiq and confirm
openbuild.conduction.nl301s tobuildiq.conduction.nlwith the path preserved, before the remaining 20 apps go anywhere near this.