Skip to content

discoverHttpCapabilities

function discoverHttpCapabilities(
baseUrl,
prefix,
authorization?,
acceptedMaxResponseBytes?,
fetchFn?
): Promise<HttpServerCapabilities>;

Defined in: src/client/capabilities.ts:172

Probe the server’s auth-exempt /health endpoint for HTTP capabilities.

The probe is HEAD, not OPTIONS, because OPTIONS cannot be used from a browser. It carries VGI-Accept-Max-Response-Bytes, which makes it a non-simple request, so the browser preflights it and asks Access-Control-Request-Method: OPTIONS — and a server answers a preflight with the methods its /health route actually implements, which is GET and HEAD. The probe is blocked before it is sent, and the error names a method nobody wrote. Every browser consumer hit this; each had to shim fetch to get a connection at all.

HEAD is equivalent for this purpose and is what the spec asks for: {prefix}/health answers GET, HEAD, OPTIONS and carries the capability headers on all three (WIRE_PROTOCOL.md §10). The C++ client already probes with HEAD, so this also removes a divergence between the ports rather than adding one.

Parameter Type Default value
baseUrl string undefined
prefix string undefined
authorization? string undefined
acceptedMaxResponseBytes? number undefined
fetchFn? typeof fetch globalThis.fetch

Promise<HttpServerCapabilities>