Core Types
RouteInfo
string
The hostname to match against the Host header (e.g., “api.localhost”, “app.myproject.localhost”)
number
The local port number where the application is listening (e.g., 3000, 4000)
RouteMapping
RouteInfo with process tracking. Used internally by RouteStore to manage route ownership and lifecycle.
number
Process ID of the application that registered this route. Use
process.pid for the current process, or 0 for system-managed routes that should never be automatically cleaned up.ProxyServerOptions
createProxyServer().
() => RouteInfo[]
required
Callback function invoked on every request to retrieve the current route table. This enables dynamic routing where routes can be added/removed without restarting the server.
number
required
The port number the proxy server is listening on. Used to construct correct URLs in error pages and route listings.
(message: string) => void
Optional error logger called when proxy errors occur. Defaults to
console.error if not provided.TLSOptions
Optional TLS configuration. When provided, enables HTTP/2 over TLS with HTTP/1.1 fallback.
ProxyServer
createProxyServer(). When TLS is disabled, returns an http.Server. When TLS is enabled, returns a net.Server that wraps both HTTP/2 and HTTP/1.1 servers.
Example:
Error Types
RouteConflictError
RouteStore.addRoute() when attempting to register a hostname that’s already in use by a live process (unless force: true is specified).
string
The hostname that caused the conflict
number
Process ID of the process that currently owns the hostname
Constants
PORTLESS_HEADER
File Permissions
RouteStore.
Import Examples
ESM (Recommended)
CommonJS
Type Guards
isValidRoute (Internal)
While not exported, here’s howRouteStore validates route data:
Related
API Overview
Getting started with the programmatic API
createProxyServer
Create proxy servers
RouteStore
Manage route mappings