tweaks to monoservice to return ns doc

This commit is contained in:
Devin Zuczek
2026-07-20 18:23:31 -04:00
parent 9ab4199bd5
commit 30bb6a131c
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -13,8 +13,8 @@
* http://localhost:8787/match/player/login -> match app sees /player/login * http://localhost:8787/match/player/login -> match app sees /player/login
* http://localhost:8787/api/api/config/v2 -> api app sees /api/config/v2 * http://localhost:8787/api/api/config/v2 -> api app sees /api/config/v2
* *
* A bare hit to the facade's own host (mono.<domain>) has no service subdomain and no * A request with no path (just `/`) that selects no service serves the `ns` discovery
* prefix, so it falls back to the `ns` discovery worker — clients bootstrap from there. * 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 * 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 * 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) } return { name: first as ServiceName, request: new Request(url, request) }
} }
// The facade's own host (mono.<domain>) carries no service subdomain. Fall back to // No service selected and no path (just `/`): serve the `ns` discovery document so a
// the `ns` discovery worker so a bare hit returns the service map, like the apex/ns host. // bare hit to the facade returns the service map, like the apex/ns host.
if (sub === 'mono') return { name: 'ns', request } if (url.pathname === '/') return { name: 'ns', request }
return undefined return undefined
} }
@@ -21,8 +21,8 @@ describe('mono routing', () => {
expect(res.headers.get('content-type')).toContain('application/json') expect(res.headers.get('content-type')).toContain('application/json')
}) })
test('the facade host (mono.<domain>) falls back to the ns discovery worker', async () => { test('root path (no service, no prefix) serves the ns discovery document', async () => {
const res = await exports.default.fetch('https://mono.recflare.net/') const res = await exports.default.fetch(`${ORIGIN}/`)
expect(res.status).toBe(200) expect(res.status).toBe(200)
// The ns worker serves the service-discovery document. // The ns worker serves the service-discovery document.
expect(await res.json()).toHaveProperty('Auth') expect(await res.json()).toHaveProperty('Auth')