Skip to content

feat(dev-server): support allowedHosts (Codespaces / ngrok / *.localhost) #144

Description

@lukekania

Goal

Honor the allowedHosts array on the dev-server builder so projects running behind tunneling proxies (ngrok, Cloudflare Tunnel, GitHub Codespaces) or non-default local hostnames (*.localhost, app.local) don't get rejected by the dev server's host-header check.

Current state

allowedHosts is silently dropped. tiny_http doesn't enforce host-header checking by default, so today ngc-rs accepts any Host: header — which is permissive but doesn't give users the security knob @angular/build:dev-server exposes (and which Vite-based dev servers default to enforcing).

Scope

  • packages/builder/schemas/dev-server.json: add allowedHosts: { type: array, items: { type: string } }. Special values: "all" (accept any), "auto" (accept localhost + the bound host).
  • packages/builder/src/serve/options.ts: forward as --allowed-hosts <list>.
  • crates/cli/src/serve_cmd.rs + crates/dev-server/: filter incoming requests by Host: header, reject mismatches with 403. Default behavior matches @angular/build's — accept localhost, 127.0.0.1, [::1], auto-mode resolves from the bind address.

Definition of done

  • "allowedHosts": ["my-app.ngrok.io"] lets ngrok-tunneled traffic through.
  • "allowedHosts": ["all"] disables the check entirely.
  • A request to a non-allowed host (default: anything other than localhost) gets a 403 with a clear error body.

Refs

Angular docs: https://angular.dev/cli/serve#options ("allowedHosts")

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestparity:importantClose before the v1.x line ends. Some apps need this; many can work around.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions