Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ To stop everything: `docker compose down` (add `-v` to wipe the database).
in use` from `ng serve`): run `lsof -nP -iTCP:5432 -iTCP:9092 -iTCP:8081 -iTCP:4200 -sTCP:LISTEN`
and `docker ps`. Stop the other project's container (`docker stop <name>`; its data is kept)
or process, or run Angular on 4201 (`npx ng serve --port 4201`). The backend only allows
browser origins 4200 and 4201, so other ports get a CORS 403 on login.
browser origins 4200 and 4201 (on `localhost` or `127.0.0.1`), so other ports get a CORS 403 on login.
- **`127.0.0.1:4200` does not load:** `ng serve` is set to listen on `127.0.0.1` in
`angular.json`, so both `http://localhost:4200` and `http://127.0.0.1:4200` work. An older
checkout listened only on IPv6 `::1`, where only `localhost` worked.
- **Login fails or the app shows the old demo-token screen:** an old backend is still running
on 8081. Stop it (Ctrl+C, or `pkill -f spring-boot:run`), start it again with the command
above, and hard-refresh the browser.
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ crm:
ttl: ${CRM_JWT_TTL:15m}
# Browser origins allowed to call /api/** cross-origin (ng serve). The k3s Ingress serves
# UI and API from one origin, so production needs no CORS entry.
cors-allowed-origins: ${CRM_CORS_ALLOWED_ORIGINS:http://localhost:4200,http://localhost:4201,http://127.0.0.1:4201}
cors-allowed-origins: ${CRM_CORS_ALLOWED_ORIGINS:http://localhost:4200,http://127.0.0.1:4200,http://localhost:4201,http://127.0.0.1:4201}
# Synthetic demo accounts. A blank password disables the account (no built-in default).
# Supply a BCrypt hash ($2a$...) in deployed environments; plain values are hashed at boot.
users:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ void corsPreflight_allowsLocalAngularOrigin_only() throws Exception {
.header("Access-Control-Request-Headers", "authorization"))
.andExpect(status().isOk())
.andExpect(header().string("Access-Control-Allow-Origin", "http://localhost:4200"));
mockMvc
.perform(
options("/api/v1/customers")
.header("Origin", "http://127.0.0.1:4200")
.header("Access-Control-Request-Method", "GET")
.header("Access-Control-Request-Headers", "authorization"))
.andExpect(status().isOk())
.andExpect(header().string("Access-Control-Allow-Origin", "http://127.0.0.1:4200"));
mockMvc
.perform(
options("/api/v1/customers")
Expand Down
3 changes: 3 additions & 0 deletions frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"host": "127.0.0.1"
},
"configurations": {
"production": {
"buildTarget": "lab50-crm-ui:build:production"
Expand Down
Loading