File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed
Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -65,4 +65,5 @@ So either notation works in deployment config.
6565
6666- [Configuration](configuration.md) — Environment variables and CLI flags
6767- [Getting Started](getting-started.md) — Install, build, and run
68+ - [Development](development.md) — Includes a local Traefik fixture for testing `/qwerty` base-path routing
6869- [Benchmarks](benchmarks.md) — spa-to-http vs Nginx
Original file line number Diff line number Diff line change @@ -85,6 +85,40 @@ docker run --rm -p 8080:8080 -v $(pwd)/test/frontend/dist:/code devforth/spa-to-
8585
8686Open ` http://localhost:8080 ` in your browser.
8787
88+ ## Prod-like Local Test: Traefik + Base Path ` /qwerty `
89+
90+ Use the local fixture at ` test/traefik/docker-compose.base-path.yml ` to emulate production routing:
91+ - ` spa-to-http ` serves only ` ${SPA_BASE_PATH} ` paths (default: ` /qwerty ` )
92+ - non-base-path requests are routed to a different backend (` whoami ` )
93+ - ` spa-to-http ` image is built locally from this repository
94+
95+ Run from repository root:
96+
97+ ``` bash
98+ SPA_BASE_PATH=/qwerty SPA_MODE=true \
99+ docker compose -f test/traefik/docker-compose.base-path.yml up --build
100+ ```
101+
102+ Verify behavior:
103+
104+ ``` bash
105+ # SPA (should return your app index)
106+ curl -i http://localhost:8081/qwerty
107+
108+ # SPA asset under base path (should be served by spa-to-http)
109+ curl -i http://localhost:8081/qwerty/vite.svg
110+
111+ # Not SPA (should be routed to whoami, not your app)
112+ curl -i http://localhost:8081/
113+ curl -i http://localhost:8081/anything
114+ ```
115+
116+ Stop:
117+
118+ ``` bash
119+ docker compose -f test/traefik/docker-compose.base-path.yml down
120+ ```
121+
88122## See Also
89123
90124- [ Getting Started] ( getting-started.md ) — Fast Docker onboarding
Original file line number Diff line number Diff line change 1+ services :
2+ traefik :
3+ image : traefik:v2.11
4+ command :
5+ - " --providers.docker=true"
6+ - " --providers.docker.exposedbydefault=false"
7+ - " --entrypoints.web.address=:8081"
8+ ports :
9+ - " 8081:8081"
10+ volumes :
11+ - " /var/run/docker.sock:/var/run/docker.sock:ro"
12+
13+ spa :
14+ image : spa-to-http-local:test
15+ build :
16+ context : ../..
17+ dockerfile : Dockerfile
18+ command : --base-path ${SPA_BASE_PATH:-/qwerty} --directory /code --spa=${SPA_MODE:-true}
19+ volumes :
20+ - " ../frontend/dist:/code:ro"
21+ labels :
22+ - " traefik.enable=true"
23+ - " traefik.http.routers.spa.rule=Host(`localhost`) && (Path(`${SPA_BASE_PATH:-/qwerty}`) || PathPrefix(`${SPA_BASE_PATH:-/qwerty}/`))"
24+ - " traefik.http.routers.spa.entrypoints=web"
25+ - " traefik.http.routers.spa.priority=100"
26+ - " traefik.http.services.spa.loadbalancer.server.port=8080"
27+
28+ other :
29+ image : traefik/whoami:v1.10
30+ labels :
31+ - " traefik.enable=true"
32+ - " traefik.http.routers.other.rule=Host(`localhost`) && PathPrefix(`/`)"
33+ - " traefik.http.routers.other.entrypoints=web"
34+ - " traefik.http.routers.other.priority=1"
35+ - " traefik.http.services.other.loadbalancer.server.port=80"
You can’t perform that action at this time.
0 commit comments