Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions docs/contributing/setup-manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ This project uses the following resources:
`PACKAGE_APP_BASE_URL` is set without `APP_BASE_URL` rather than publishing
a partial set. Any domain attached out-of-band must be added here before the
next deploy, or that deploy will remove it.
- The route deliberately does **not** live in
`packages/worker/wrangler.jsonc`: `npm run dev` runs `wrangler dev` against
the **production** environment, and Wrangler resolves local request URLs
against the first configured route, so a committed route makes every local
request arrive as `http://kodyapps.dev/...` — canonical URLs, OAuth resource
metadata, and login redirects then point at the production domain from
localhost.
- Publishing routes also flips `workers_dev` to `false`, which silently drops
the `<name>.<subdomain>.workers.dev` trigger (Cloudflare then answers that
hostname with error 1042). The generator sets `workers_dev: true` alongside
the routes so that backup access path — which MCP clients may point at, and
which the deploy's URL fallback looks for — survives.
- The routes deliberately do **not** live in `packages/worker/wrangler.jsonc`:
`npm run dev` runs `wrangler dev` against the **production** environment,
and Wrangler resolves local request URLs against the first configured route,
so a committed route makes every local request arrive as
`http://kodyapps.dev/...` — canonical URLs, OAuth resource metadata, and
login redirects then point at the production domain from localhost.
- The app origin (`heykody.dev`) stays attached out-of-band; Wrangler does not
remove routes that the config omits.
- Attaching a custom domain needs a deploy token with edit access to the
Expand Down
6 changes: 5 additions & 1 deletion tools/ci/resource-utils.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ test('writeGeneratedWranglerConfig preserves migrations and copies environment a
assets?: { run_worker_first?: Array<string> }
r2_buckets?: Array<{ binding: string; bucket_name: string }>
routes?: Array<{ pattern: string; custom_domain?: boolean }>
workers_dev?: boolean
vars?: Record<string, unknown>
}
}
Expand Down Expand Up @@ -114,6 +115,8 @@ test('writeGeneratedWranglerConfig preserves migrations and copies environment a
custom_domain: true,
},
])
// Publishing routes otherwise drops the workers.dev trigger.
expect(productionConfig.env?.production?.workers_dev).toBe(true)

const previewOutPath = path.join(tempDir, 'wrangler-preview.generated.json')
await writeGeneratedWranglerConfig({
Expand Down Expand Up @@ -150,8 +153,9 @@ test('writeGeneratedWranglerConfig preserves migrations and copies environment a
{ binding: 'EMAIL_BLOBS', bucket_name: 'kody-pr-123-email-blobs' },
])
// Preview serves package apps inline on its own origin, so it publishes no
// routes and keeps whatever domains are attached out-of-band.
// routes and keeps whatever domains and triggers it already had.
expect(previewConfig.env?.preview?.routes).toBeUndefined()
expect(previewConfig.env?.preview?.workers_dev).toBeUndefined()
expect(consoleError).toHaveBeenCalledWith(
`Wrote generated Wrangler config: ${previewOutPath}`,
)
Expand Down
7 changes: 6 additions & 1 deletion tools/ci/resource-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,13 @@ function addPackageAppCustomDomainRoute(input: {
.filter((hostname) => !routedHostnames.has(hostname))
.map((pattern) => ({ pattern, custom_domain: true })),
]
// Publishing routes flips `workers_dev` to false, which removed the
// `<name>.<subdomain>.workers.dev` trigger the deploy previously kept as a
// backup access path (and that MCP clients may be pointed at). Ask for it
// explicitly so adding a custom domain does not silently take it away.
input.targetEnv.workers_dev = true
console.error(
`Custom domain routes: ${appHostname} (APP_BASE_URL), ${packageAppHostname} (PACKAGE_APP_BASE_URL)`,
`Custom domain routes: ${appHostname} (APP_BASE_URL), ${packageAppHostname} (PACKAGE_APP_BASE_URL); workers.dev trigger kept`,
)
}

Expand Down
Loading