Files
bowenliang123 f4db11776f fix(client): ride the fetch routes as browser-relative spellings
The client POSTed every plugin route as a root-absolute /api/dsh-context/*
path, which stripped a reverse proxy's /app/dsh prefix at the gateway —
every poll 404ed at it, the panel retried on an aggressive backoff, and
the deployment fell into the issue #159 reconnect loop. The six route
constants now live in one module as their browser-relative spellings:
fetch resolves them against the page's document base, the same idiom
dsh's own stream/socket clients ride, so a prefixed proxy keeps its
prefix and a direct deployment resolves to the exact same URLs before
and after. A host/client pairing spec pins each spelling to its route
registration, and docs/compatibility.md gains the §5.8 client-seam rule.

Fixes #159
2026-10-16 23:50:58 +08:00

32 lines
1.2 KiB
TypeScript

import assert from 'node:assert/strict'
import { describe, test } from 'vitest'
import { BALANCE_ROUTE as HOST_BALANCE_ROUTE } from '../../src/host/balance'
import { DETAIL_ROUTE as HOST_DETAIL_ROUTE } from '../../src/host/detail'
import { ATTACHMENT_ROUTE as HOST_ATTACHMENT_ROUTE } from '../../src/host/attachment'
import { BACKFILL_ROUTE as HOST_BACKFILL_ROUTE } from '../../src/host/backfill'
import { FLEET_ROUTE as HOST_FLEET_ROUTE } from '../../src/host/fleet'
import { SKILLS_ROUTE as HOST_SKILLS_ROUTE } from '../../src/host/skills'
import {
ATTACHMENT_ROUTE,
BACKFILL_ROUTE,
BALANCE_ROUTE,
DETAIL_ROUTE,
FLEET_ROUTE,
SKILLS_ROUTE,
} from '../../src/client/apiRoutes'
describe('apiRoutePairing', () => {
test('each client fetch route is its host registration minus the leading slash', () => {
for (const [host, client] of [
[HOST_DETAIL_ROUTE, DETAIL_ROUTE],
[HOST_BALANCE_ROUTE, BALANCE_ROUTE],
[HOST_FLEET_ROUTE, FLEET_ROUTE],
[HOST_SKILLS_ROUTE, SKILLS_ROUTE],
[HOST_BACKFILL_ROUTE, BACKFILL_ROUTE],
[HOST_ATTACHMENT_ROUTE, ATTACHMENT_ROUTE],
]) {
assert.equal(client, host.slice(1), `${host} and ${client} lost their pairing`)
}
})
})