Skip to content

fix(site): force gate worker to run before serving static assets - #51

Merged
bryanfawcett merged 1 commit into
mainfrom
claude/docs-gate-run-worker-first
Aug 1, 2026
Merged

fix(site): force gate worker to run before serving static assets#51
bryanfawcett merged 1 commit into
mainfrom
claude/docs-gate-run-worker-first

Conversation

@bryanfawcett

Copy link
Copy Markdown
Contributor

Summary

  • Verified live after docs+feat: Fly.io Agent Gateway docs, and gate internal sections behind auth #48/fix(site): use the shared Nyuchi Internal Tools WorkOS app for the docs gate #50 deployed: curl https://docs.nyuchi.com/deployment/agentgateway/ returned a plain 200, not the expected 302 to WorkOS login. The gate's fetch handler wasn't running at all.
  • Root cause: Cloudflare's Workers Static Assets serves a request directly from the asset router whenever its path matches a real file in dist/, bypassing the Worker's fetch() entirely — and every visibility: internal page is a real file.
  • Fix: run_worker_first = true in [assets] — routes every request through src/worker/gate.ts first; it still calls env.ASSETS.fetch() itself for public paths and authorized internal ones, so behavior for everything else is unchanged.

Test plan

  • wrangler deploy --dry-run — bundles clean, same bindings
  • Once deployed, re-verify curl -I https://docs.nyuchi.com/deployment/agentgateway/ returns 302 to identity.nyuchi.com

Generated by Claude Code

Verified live: internal pages returned a plain 200 with none of the
gate's redirect/cookie logic, because Cloudflare serves a request
straight from the asset router whenever its path matches a real file
in dist/ — which every visibility: internal page does. The gate's
fetch handler in src/worker/gate.ts never ran at all.

run_worker_first = true routes every request through the Worker
first; it calls env.ASSETS.fetch() itself for public paths and
already-authorized internal ones, same as before.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
nyuchi-docs-mcp c681e53 Commit Preview URL

Branch Preview URL
Aug 01 2026, 02:25 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shamwari-docs-ai c681e53 Commit Preview URL

Branch Preview URL
Aug 01 2026, 02:25 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
nyuchi-docs c681e53 Commit Preview URL

Branch Preview URL
Aug 01 2026, 02:26 AM

@bryanfawcett
bryanfawcett marked this pull request as ready for review August 1, 2026 08:07
@bryanfawcett
bryanfawcett merged commit 5cdc181 into main Aug 1, 2026
7 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.

2 participants