diff --git a/services/meta/README.md b/services/meta/README.md index 85661af69af..18d16cb08db 100644 --- a/services/meta/README.md +++ b/services/meta/README.md @@ -1,7 +1,9 @@ # Meta Machine-readable files that clients fetch from fixed `opencode.ai` URLs. They are -not part of the website, so they live in their own Worker, one exact route per path. +not part of the website, so they live in their own Worker with one `*` route +per path. The `*` lets requests with a query string through; anything that isn't +exactly one of the paths gets a 404. | Path | Source | | ----------------------------------------- | --------------------------------------------------------------------------------------- | diff --git a/services/meta/cloudflare.config.ts b/services/meta/cloudflare.config.ts index ebaa7f249ee..5b45f94d0e9 100644 --- a/services/meta/cloudflare.config.ts +++ b/services/meta/cloudflare.config.ts @@ -2,8 +2,9 @@ import { bindings, defineConfig, triggers } from "cf/config" import { PATHS } from "./src/paths.ts" // `--mode dev` builds and deploys the dev Worker on dev.opencode.ai; any other mode is production on opencode.ai. -// Each path gets its own exact route so the Worker never catches anything else on the zone. Exact routes win over -// the website's Custom Domain. +// Each path gets its own route, and the routes win over the website's Custom Domain. An exact pattern misses +// `/config.json?query`, and route patterns can't match a query string, so each one is a `*` prefix. No other +// route or site path starts with these, and the Worker 404s anything that isn't exactly one of its paths. export default defineConfig(({ mode }) => { const dev = mode === "dev" const host = dev ? "dev.opencode.ai" : "opencode.ai" @@ -12,11 +13,12 @@ export default defineConfig(({ mode }) => { name: dev ? "opencode-dev-meta" : "opencode-production-meta", compatibilityDate: "2026-08-01", entrypoint: "./src/index.ts", - assets: {}, + // Assets match only their exact path, so /config.json/ or /tui.json.gz fall through to the Worker's 404. + assets: { htmlHandling: "none", notFoundHandling: "none" }, env: { ASSETS: bindings.assets(), }, - triggers: Object.values(PATHS).map((path) => triggers.fetch({ pattern: `${host}${path}`, zone: "opencode.ai" })), + triggers: Object.values(PATHS).map((path) => triggers.fetch({ pattern: `${host}${path}*`, zone: "opencode.ai" })), workersDev: false, previewUrls: false, }, diff --git a/services/meta/src/paths.ts b/services/meta/src/paths.ts index d0bc5459977..7ec36b75b27 100644 --- a/services/meta/src/paths.ts +++ b/services/meta/src/paths.ts @@ -1,4 +1,4 @@ -// Every path this Worker serves. Each one is also an exact route, see cloudflare.config.ts. +// Every path this Worker serves. Each one is also a `*` route, see cloudflare.config.ts. export const PATHS = { config: "/config.json", tui: "/tui.json",