From 30bb6a131c98be6ca426ab137c244d88a5a3eb71 Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Mon, 20 Jul 2026 18:23:31 -0400 Subject: [PATCH] tweaks to monoservice to return ns doc --- apps/mono/src/mono.app.ts | 10 +++++----- apps/mono/src/test/integration/routing.test.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/mono/src/mono.app.ts b/apps/mono/src/mono.app.ts index 269f181..0b43388 100644 --- a/apps/mono/src/mono.app.ts +++ b/apps/mono/src/mono.app.ts @@ -13,8 +13,8 @@ * 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. + * A request with no path (just `/`) that selects no service serves the `ns` discovery + * document, so a bare hit to the facade root returns the service map to bootstrap from. * * 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 @@ -83,9 +83,9 @@ 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 } + // No service selected and no path (just `/`): serve the `ns` discovery document so a + // bare hit to the facade returns the service map, like the apex/ns host. + if (url.pathname === '/') 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 316e3ed..9e05483 100644 --- a/apps/mono/src/test/integration/routing.test.ts +++ b/apps/mono/src/test/integration/routing.test.ts @@ -21,8 +21,8 @@ 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/') + test('root path (no service, no prefix) serves the ns discovery document', async () => { + const res = await exports.default.fetch(`${ORIGIN}/`) expect(res.status).toBe(200) // The ns worker serves the service-discovery document. expect(await res.json()).toHaveProperty('Auth')