Skip to content

Commit ace71bd

Browse files
authored
Merge pull request #67 from constk/develop
release: sync main with develop (Vite proxy fix + README screenshots)
2 parents ab89e45 + 829e954 commit ace71bd

5 files changed

Lines changed: 38 additions & 11 deletions

File tree

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,30 @@ Required test coverage of 75.0% reached. Total coverage: 98.64%
6868

6969
### CI on a sample PR
7070

71-
Eight backend + two frontend + four security jobs all green on every PR:
71+
Ten jobs across `ci.yml` (eight backend + two frontend) — all green:
7272

7373
![CI status](docs/images/ci-green.png)
7474

75-
> **Capture:** open <https://github.com/constk/harness-python-react/actions/workflows/ci.yml>, click any green run on `develop`, screenshot the job-list panel. Save as `docs/images/ci-green.png`.
75+
The four security-workflow jobs (gitleaks, pip-audit, npm audit, trivy) gate every PR alongside this set; see the [Security workflow runs](https://github.com/constk/harness-python-react/actions/workflows/security.yml).
7676

77-
### Hello page (`docker compose up`)
77+
### Hello page (`npm run dev` / `docker compose up`)
7878

79-
The scaffold's React page hits `/api/v1/health` on load and renders the version + status badge:
79+
The scaffold's React page hits `/api/v1/health` on load and renders the version + status badge. The Vite dev server proxies `/api/*` to the FastAPI backend (target overridable via `VITE_API_PROXY_TARGET`):
8080

8181
![Hello page](docs/images/hello-page.png)
8282

83-
> **Capture:** `docker compose up`, open <http://localhost:5173>, screenshot.
83+
<!--
84+
TODO (#28): one capture left — Jaeger trace.
8485
85-
### Jaeger trace for `/api/v1/health`
86+
docs/images/jaeger-trace.png
87+
With the full stack running (`docker compose up`), hit /api/v1/health
88+
once, then open http://localhost:16686, select service
89+
`harness-python-react`, click the most recent trace, screenshot the
90+
span timeline.
8691
87-
OTel auto-instrumentation produces one span per request, exported via OTLP gRPC to the local Jaeger:
88-
89-
![Jaeger trace](docs/images/jaeger-trace.png)
90-
91-
> **Capture:** with the stack running, hit `/api/v1/health` once, then open <http://localhost:16686>, select service `harness-python-react`, click the most recent trace, screenshot the span timeline.
92+
When the PNG lands in docs/images/, replace this comment with a section
93+
analogous to "Hello page" above.
94+
-->
9295

9396
## Why a harness
9497

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ services:
3030
- "5173:5173"
3131
depends_on:
3232
- app
33+
environment:
34+
# Vite dev-server proxy target. Inside the compose network, the
35+
# backend service is reachable at http://app:8000. The browser
36+
# still hits http://localhost:5173/api/v1/* and Vite proxies it.
37+
- VITE_API_PROXY_TARGET=http://app:8000
3338
# Bind-mount the source so Vite HMR sees host edits. node_modules stays
3439
# inside the container so platform-native deps aren't shadowed.
3540
volumes:

docs/images/ci-green.png

27.4 KB
Loading

docs/images/hello-page.png

38.5 KB
Loading

frontend/vite.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
33

4+
// `/api/*` calls from the React app are proxied to the FastAPI backend so
5+
// the dev experience matches a same-origin production deployment. Without
6+
// this Vite serves `index.html` for `/api/*`, which the browser then tries
7+
// to JSON.parse — producing "Unexpected token '<'".
8+
//
9+
// Override the target via env when needed:
10+
// - Local (no Docker): defaults to http://localhost:8000.
11+
// - docker-compose: set VITE_API_PROXY_TARGET=http://app:8000 (inside
12+
// the compose network the backend hostname is `app`).
13+
const API_PROXY_TARGET = process.env.VITE_API_PROXY_TARGET ?? 'http://localhost:8000'
14+
415
// https://vite.dev/config/
516
export default defineConfig({
617
plugins: [react()],
18+
server: {
19+
proxy: {
20+
'/api': {
21+
target: API_PROXY_TARGET,
22+
changeOrigin: true,
23+
},
24+
},
25+
},
726
})

0 commit comments

Comments
 (0)