From 9ab4199bd5750072eda5082d88eb5efba2217f07 Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Mon, 20 Jul 2026 18:15:20 -0400 Subject: [PATCH] tweak for returning ns --- apps/mono/package.json | 1 - apps/mono/src/mono.app.ts | 7 +++++++ apps/mono/src/test/integration/routing.test.ts | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/mono/package.json b/apps/mono/package.json index bac94cb..2b6f3cb 100644 --- a/apps/mono/package.json +++ b/apps/mono/package.json @@ -9,7 +9,6 @@ "check:lint": "run-oxlint", "check:types": "run-tsc", "check:workers-types": "run-wrangler-types --check", - "deploy": "run-wrangler-deploy", "dev": "run-wrangler-dev", "fix:workers-types": "run-wrangler-types", "test": "run-vitest" diff --git a/apps/mono/src/mono.app.ts b/apps/mono/src/mono.app.ts index 58ab316..269f181 100644 --- a/apps/mono/src/mono.app.ts +++ b/apps/mono/src/mono.app.ts @@ -13,6 +13,9 @@ * http://localhost:8787/match/player/login -> match app sees /player/login * http://localhost:8787/api/api/config/v2 -> api app sees /api/config/v2 * + * A bare hit to the facade's own host (mono.) has no service subdomain and no + * prefix, so it falls back to the `ns` discovery worker — clients bootstrap from there. + * * NOT mounted here: `www`, `img`, `econ`. Each binds a static `assets` directory and * Cloudflare allows only one static-assets binding per Worker. Resolve that (serve * their static trees from R2, or keep those three as their own Workers) before adding. @@ -80,6 +83,10 @@ function resolve(request: Request): { name: ServiceName; request: Request } | un return { name: first as ServiceName, request: new Request(url, request) } } + // The facade's own host (mono.) carries no service subdomain. Fall back to + // the `ns` discovery worker so a bare hit returns the service map, like the apex/ns host. + if (sub === 'mono') return { name: 'ns', request } + return undefined } diff --git a/apps/mono/src/test/integration/routing.test.ts b/apps/mono/src/test/integration/routing.test.ts index a866f4e..316e3ed 100644 --- a/apps/mono/src/test/integration/routing.test.ts +++ b/apps/mono/src/test/integration/routing.test.ts @@ -21,6 +21,13 @@ describe('mono routing', () => { expect(res.headers.get('content-type')).toContain('application/json') }) + test('the facade host (mono.) falls back to the ns discovery worker', async () => { + const res = await exports.default.fetch('https://mono.recflare.net/') + expect(res.status).toBe(200) + // The ns worker serves the service-discovery document. + expect(await res.json()).toHaveProperty('Auth') + }) + test('unknown service prefix returns the facade 404', async () => { const res = await exports.default.fetch(`${ORIGIN}/nope/whatever`) expect(res.status).toBe(404)