mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 10:18:46 +03:00
fix(meta): route config schemas and well-known files with a query string to the meta worker (#62196)
This commit is contained in:
@@ -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 `<path>*` 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 |
|
||||
| ----------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||
|
||||
@@ -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 `<path>*` 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,
|
||||
},
|
||||
|
||||
@@ -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 `<path>*` route, see cloudflare.config.ts.
|
||||
export const PATHS = {
|
||||
config: "/config.json",
|
||||
tui: "/tui.json",
|
||||
|
||||
Reference in New Issue
Block a user