From fe33b983a3c47b09934b710914acca42055624a9 Mon Sep 17 00:00:00 2001 From: bisco Date: Wed, 3 Jun 2026 21:50:24 +0200 Subject: [PATCH] fix: proxy frontend API requests to backend --- docs/deployment.md | 2 ++ docs/runbook.md | 1 + frontend/package.json | 2 +- frontend/proxy.conf.json | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 frontend/proxy.conf.json diff --git a/docs/deployment.md b/docs/deployment.md index 61220e9..143c830 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -24,6 +24,8 @@ docker compose run --rm backend python manage.py createsuperuser PostgreSQL is not published to the host. +During local development, the Angular dev server proxies `/api`, `/api-auth`, and `/admin` to the backend container. + ## Volumes - `postgres_data`: PostgreSQL data. diff --git a/docs/runbook.md b/docs/runbook.md index 576afff..7d7b423 100644 --- a/docs/runbook.md +++ b/docs/runbook.md @@ -24,6 +24,7 @@ docker compose run --rm backend python manage.py createsuperuser - If the frontend shows an authentication error, sign in through `http://localhost:8000/admin/` or DRF login first. - If the frontend serves a blank page, check `docker compose logs frontend`. Cache permission errors should be resolved by the configured `/tmp/angular-cache` path; restart with `docker compose up -d frontend`. +- If the frontend loads but player data does not, confirm that `frontend/proxy.conf.json` is active and restart the frontend container. - If backend startup fails, check database readiness with `docker compose logs db`. - If dependencies change, rebuild with `docker compose build --no-cache backend frontend`. diff --git a/frontend/package.json b/frontend/package.json index b6a895b..e5868c7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "start": "ng serve --host 0.0.0.0 --port 4200", + "start": "ng serve --host 0.0.0.0 --port 4200 --proxy-config proxy.conf.json", "build": "ng build", "test": "tsx --import ./src/test-setup.ts --test \"src/**/*.spec.ts\"", "typecheck": "tsc --noEmit -p tsconfig.json" diff --git a/frontend/proxy.conf.json b/frontend/proxy.conf.json new file mode 100644 index 0000000..ba418c2 --- /dev/null +++ b/frontend/proxy.conf.json @@ -0,0 +1,17 @@ +{ + "/api": { + "target": "http://backend:8000", + "secure": false, + "changeOrigin": false + }, + "/api-auth": { + "target": "http://backend:8000", + "secure": false, + "changeOrigin": false + }, + "/admin": { + "target": "http://backend:8000", + "secure": false, + "changeOrigin": false + } +}