Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.

Make ng serve answer on both localhost and 127.0.0.1 - #33

Merged
WillCraig merged 1 commit into
mainfrom
chore/ng-serve-host
Oct 22, 2026
Merged

WillCraig merged 1 commit into
mainfrom
chore/ng-serve-host

Conversation

@WillCraig

Copy link
Copy Markdown
Owner

What changed:

  • angular.json: ng serve now listens on 127.0.0.1. Before, it listened only on IPv6 ::1, so http://127.0.0.1:4200 refused to connect and only localhost worked. Browsers and curl fall back from ::1 to 127.0.0.1 for localhost, so both URLs load now.
  • application.yml: added http://127.0.0.1:4200 to the default CORS origins. Without it, a browser on 127.0.0.1:4200 would get a CORS 403 on login. The list already had 127.0.0.1:4201.
  • SecurityIT: the preflight test also checks the 127.0.0.1:4200 origin.
  • README troubleshooting note.

Why: if someone types the IP during the demo, it should just work.

How tested:

  • ng serve --port 4303: curl gives 200 on both http://localhost:4303/ and http://127.0.0.1:4303/. Headless Chrome renders the login page on both. lsof shows it listening on 127.0.0.1.
  • mvn -B clean verify: 99 tests, 0 failures.
  • Backend jar on 8091: a preflight from http://127.0.0.1:4200 gets 200, from http://localhost:4200 gets 200, and from https://evil.example gets 403.

Note: a running backend needs a restart to pick up the new CORS origin.

@WillCraig
WillCraig merged commit 9b2e656 into main Oct 22, 2026
7 checks passed
@WillCraig
WillCraig deleted the chore/ng-serve-host branch October 22, 2026 13:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant