Route /api/* through the Worker so subscribe actually runs - #125
Conversation
`run_worker_first` only listed "/", so Cloudflare's asset server answered /api/subscribe before the Worker ever ran and rejected the POST with a bare 405. The subscribe form has been broken since it shipped: every signup was dropped and the visitor saw a generic error, which is why the Resend "Blog" audience is empty and `just deploy live` fails to announce. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RibbEtTdquFTTLJNEvrAn9
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe asset configuration now routes Merge Risk: ⚪ Minimal · up to This localized routing configuration change enables API requests to reach the Worker so subscriptions can run; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`go get` resolves an import path by fetching it over HTTPS with ?go-get=1 and reading the repo out of a <meta name="go-import"> tag, so serving that tag here makes moq.dev own the published import path instead of whichever mirror repo the code lands in. The Go wrapper can then be imported as `moq.dev/moq` rather than `github.com/moq-dev/moq-go/moq`, which also means the identifier is `moq` with no alias, and a future mirror rename costs a line in the table rather than a breaking change for every consumer. Two paths are served, both inert until the matching go.mod switches its module path: moq.dev/moq -> github.com/moq-dev/moq-go moq.dev/moq-ffi -> github.com/moq-dev/moq-go-ffi A module owns every path beneath it, because the go command asks about the full import path (package directory included) and the tag has to answer with the module path regardless. Requests without ?go-get=1 are people, so they redirect to pkg.go.dev. `run_worker_first` needs the /moq* wildcard for the same reason #125 needed /api/*: an asset miss is answered with the 404 page rather than falling through, so the Worker would never run. Verified against `wrangler dev`, which reproduces that routing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`go get` resolves an import path by fetching it over HTTPS with ?go-get=1 and reading the repo out of a <meta name="go-import"> tag, so serving that tag here makes moq.dev own the published import path instead of whichever mirror repo the code lands in: moq.dev/moq -> github.com/moq-dev/moq-go moq.dev/moq-ffi -> github.com/moq-dev/moq-go-ffi Both are inert until the matching go.mod switches its module path, which is the correct order: the tags have to be live before a mirror publishes a moq.dev/... go.mod, or the first tag that lands resolves to nothing. A module owns every path beneath it, because the go command asks about the full import path while the tag has to answer with the module path regardless. Requests without ?go-get=1 are people, so they redirect to pkg.go.dev, and the de.moq.dev rewrite runs first so that host keeps its own namespace. run_worker_first needs the /moq* wildcard for the same reason #125 needed /api/*: an asset miss is answered with the 404 page rather than falling through, so the Worker would never run. CI also runs `bun test` now, which it never did, leaving every test in the repo unenforced.
What
One line in
wrangler.jsonc:run_worker_firstnow lists/api/*alongside/.Why
just deploy livefailed its announce step with a Resend 422: "The audience you are sending has no contacts." The audience is empty because the subscribe form has never worked.run_worker_firstonly listed"/", so for every other path Cloudflare's static asset server answers before the Worker runs./api/subscribeisn't an asset, and the asset server rejects a POST to a non-asset path with a bare 405 — the Worker'shandleSubscribenever executes.Confirmed against production:
POST https://moq.dev/api/subscribe→405with an empty body. The Worker's own 405 branch returns the stringMethod Not Allowed, so this response isn't coming from our code.GET https://moq.dev/api/subscribe→ the asset404page.new.moq.devbehaves the same way.So every visitor who submitted the form got "Something went wrong. Try again?" and their address was silently dropped.
The rest of the chain is healthy and needed no changes:
RESEND_API_KEYandRESEND_SEGMENT_IDare both set as secrets on the live Worker, and the handler'sPOST /contactswith asegments: [{ id }]array matches Resend's current API reference.This is the same footgun
CLAUDE.mdalready documents for moq.pub / moq.watch, whereassets.run_worker_firstis called out as load-bearing — it just bit the moq.dev Worker on a different path.Verifying after deploy
Should return
200 {"ok":true}and the address should appear in the Resend "Blog" segment. Before this change it's an empty405.Not fixed here
Untitleddraft broadcasts are sitting in Resend from the deploy retries (15:35–16:06 UTC). Each was created fine and then failed on send. Worth cleaning up in the dashboard.(written by Fable 5)
🤖 Generated with Claude Code
https://claude.ai/code/session_01RibbEtTdquFTTLJNEvrAn9