Share localhost / Angular
Share an Angular dev server at a public URL
ng serve listens on localhost:4200, and whk share 4200 gives it an HTTPS link. The dev server's host check and its live reload both work through the link without touching angular.json.
# terminal 1: the dev server
ng serve
# terminal 2: the link
whk share 4200The link is https://<name>.sharehooks.cc and works until you press Ctrl-C. No whk yet? Install it and log in, which takes a minute.
Angular at a glance
- Dev server
ng serve, port 4200- Share it
whk share 4200- Setting to add
- None for
whk share.allowedHostsunder theservetarget is checked againstHost, which arrives aslocalhost:4200. - Without it
- Nothing through
whk share. Other tunnels get a403page:Blocked request. This host ("<host>") is not allowed. - Hot reload
- Yes. Live reload and HMR use a WebSocket on the dev server's own port, and the client connects to the host the page came from.
- URLs and cookies
- A browser-rendered app builds its URLs from the address bar, so nothing to set. With SSR,
X-Forwarded-*headers are ignored unlesstrustProxyHeadersallows them.
Your dev server gets each request with Host: localhost:4200; the public name travels in X-Forwarded-Host, with X-Forwarded-Proto: https. What your server sees has the rest.
allowedHosts in angular.json
Angular's dev server is built on Vite and answers localhost, names under .localhost and IP addresses. A request with any other Host gets a 403 page that reads Blocked request. This host ("<host>") is not allowed. and tells you to add the host to allowedHosts under the serve target in angular.json.
whk share sends Host: localhost:4200, so the check passes with the default configuration. If you work with a tunnel that passes the public hostname on, this is where the setting goes:
angular.json
"serve": {
"options": {
"allowedHosts": [".sharehooks.cc"]
}
}The same value can be given on the command line as --allowed-hosts. The older --disable-host-check and --public-host flags belong to the legacy webpack builder and are not options of the current one.
Live reload and HMR
ng serve reloads the page on change, and replaces styles and templates in place where it can; both are on by default. The messages travel over Vite's WebSocket on the dev server's own port, and the client opens it to the host the page was loaded from, so a page opened through the link connects through the link.
ng serve listens on localhost, which on many machines is the IPv6 address ::1 only. whk share 4200 tries IPv4 and then IPv6, so it finds the server either way; whk share 127.0.0.1:4200 connects to IPv4 alone and may find nothing. If the PORT environment variable is set, it takes precedence over --port, so share the port ng serve prints.
Server-side rendering and proxy headers
An app with @angular/ssr validates request headers before rendering. Host: localhost:4200 is accepted. The forwarded headers the link adds are treated as untrusted and removed, and the terminal says so on each request: Received "x-forwarded-host" header but "trustProxyHeaders" was not set up to allow it. The page still renders; the server simply believes it is on localhost.
That only matters if server-rendered output contains absolute URLs. To have the server use the public address, the security guide's trustProxyHeaders option allows chosen headers (its example is ['x-forwarded-host', 'x-forwarded-proto']), and a forwarded host that is trusted must be an allowed host as well. Angular's docs advise this only behind a proxy that overwrites those headers; the link sets X-Forwarded-Host, X-Forwarded-Proto and X-Forwarded-For itself on every request, so trust those and no others.
Angular questions
Add the hostname to allowedHosts under the serve target's options in angular.json, for example "allowedHosts": [".example.com"], or pass --allowed-hosts to ng serve. With whk share the page does not appear, because the dev server receives Host: localhost.
Not in the current builder. In Angular 22 the dev server (@angular/build:dev-server) has allowedHosts, which sets the Vite option of the same name. --disable-host-check and --public-host remain only in the legacy webpack-based builder.
Yes. The reload and HMR messages use a WebSocket on the same port as the app, and the client connects to the host the page was loaded from, so they pass through whk share.
4200 by default. ng serve --port 4300 changes it, and a PORT environment variable takes precedence over the option.
Sources
The Angular settings and messages on this page are from the official documentation and source for Angular 22, read on 12 November 2026. What the link does to a request is from the whk share docs.
Other frameworks
Send someone your Angular app
Sign up free, install the CLI and run whk share 4200.
No credit card