Skip to content

feat(server): serve HTTP-only on $PORT when TLS terminates at the edge#249

Merged
jsugg merged 1 commit into
mainfrom
feat/edge-tls-http-listener
Jul 8, 2026
Merged

feat(server): serve HTTP-only on $PORT when TLS terminates at the edge#249
jsugg merged 1 commit into
mainfrom
feat/edge-tls-http-listener

Conversation

@jsugg

@jsugg jsugg commented Jul 8, 2026

Copy link
Copy Markdown
Owner

What

Introduce a TLS_ENABLED flag so the app can serve HTTP-only on $PORT when TLS is terminated at the platform edge.

  • config.https.enabled = process.env.TLS_ENABLED !== 'false' (default on, so local and self-hosted runs keep their HTTPS listener unchanged).
  • When disabled, startApplicationRuntime binds only the plain HTTP listener and skips certificate loading and the HTTPS listener entirely — no wasted port, no certificates required.
  • Certificates still load before any listener binds, so a TLS failure aborts boot cleanly rather than leaving a half-open HTTP socket.

Why

Behind an edge that terminates TLS and routes plain HTTP to a single injected $PORT, the app's own HTTPS listener is redundant: it needs certificates that are not present in that environment and binds a second port the edge never probes. Setting TLS_ENABLED=false there makes the runtime bind exactly the one HTTP port the platform health-checks.

Tests

  • New runtime test: with httpsEnabled: false, only the HTTP server starts, certificates are never loaded, and shutdown registers a single server.
  • New config test: TLS_ENABLED=false disables config.https.enabled.
  • Existing "starts both servers" and TLS-failure cleanup tests unchanged and passing.

Add a TLS_ENABLED flag (default on). When set to false, the runtime binds
only the plain HTTP listener on $PORT and skips loading certificates and
starting the HTTPS listener — the correct posture behind a platform that
terminates TLS at its edge and routes HTTP to a single injected port.

Certificates still load before any listener binds, so a TLS failure aborts
boot cleanly instead of leaving a half-open HTTP socket.
@jsugg jsugg merged commit 2804fea into main Jul 8, 2026
21 checks passed
@jsugg jsugg deleted the feat/edge-tls-http-listener branch July 8, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant