Skip to content

Embedding URLCode in another host: export a Response adapter; server-only protections #889

Closed

Description

@jimhoyd

Found while hosting URLCode inside Hono (#887, proofs/ecosystem/). Embedding works, but only because the fixture's bridge copies core's unexported response rules. Several protections exist only in startServer.

  1. No public way to turn a runtime result into an HTTP Response. prepareResponse, prepareStream, errorResponse and the error-code table (packages/core/src/http-response.ts:50, :95, :208, :167) are unexported. The only exported Node handler, createVercelHandler, runs as the vercel target, which refuses function routes. Proposal: a small exported toResponse/fetch adapter for the self-hosted target.
  2. Trusted-proxy client resolution is server-only. compileTrustedProxies and resolveClient (client-address.ts:42, :68) are used only by startServer. Under Hono, X-Forwarded-For from a trusted proxy is ignored.
  3. The loopback Host check (421) is server-only (client-address.ts:126, server.ts:349).
  4. Other features missing under an embedded host: the health, ready and metrics probes and the readiness drain, the request log, admission, timeouts, stream limits and reload. Document them as server-only, or make them available to embedders.
  5. Repeated request headers are lost on fetch-only hosts. headerCounts is optional (runtime.ts:90), and a missing count reads as 0. That weakens the duplicate-header refusals in match.ts:98, http-policy.ts:90 and extension-http.ts:191. Fetch-only hosts should declare that they can't provide counts, and the runtime should then refuse or fall back safely.
  6. No base-path setting. Behind prefix-stripping mounts, redirects and a function's request.url lose the prefix.
  7. urlcode review flags an in-process app.fetch(request) as an outbound network call (review.ts:106).

Related: #841, #887.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions