mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
tweak for returning ns
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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.<domain>) 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.<domain>) 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
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,13 @@ describe('mono routing', () => {
|
||||
expect(res.headers.get('content-type')).toContain('application/json')
|
||||
})
|
||||
|
||||
test('the facade host (mono.<domain>) 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)
|
||||
|
||||
Reference in New Issue
Block a user