← Getting Started · Development · Back to README · Deployment →
spa-to-http supports both environment variables and CLI flags. Environment variables map directly to the CLI options.
| Environment Variable | Command | Description | Default |
|---|---|---|---|
| ADDRESS | -a or --address |
Address to use | 0.0.0.0 |
| PORT | -p or --port |
Port to listen on | 8080 |
| GZIP | --gzip |
Enable gzip compression for files above the threshold | false |
| BROTLI | --brotli |
Enable Brotli compression for files above the threshold | false |
| THRESHOLD | --threshold <number> |
Threshold in bytes for gzip and Brotli | 1024 |
| DIRECTORY | -d <string> or --directory <string> |
Directory to serve | . |
| BASE_PATH | --base-path <string> |
URL prefix to mount the SPA under (normalized path prefix) | / |
| CACHE_MAX_AGE | --cache-max-age <number> |
Cache max-age in seconds; use -1 to disable |
604800 |
| IGNORE_CACHE_CONTROL_PATHS | --ignore-cache-control-paths <string> |
Comma-separated paths to force Cache-Control: no-store |
(empty) |
| SPA_MODE | --spa or --spa <bool> |
Serve index.html on missing paths (SPA routing) |
true |
| CACHE | --cache |
Enable in-memory file read cache (LRU) | true |
| CACHE_BUFFER | --cache-buffer <number> |
Max size of the LRU cache in bytes | 51200 |
| LOGGER | --logger |
Enable request logging | false |
| LOG_PRETTY | --log-pretty |
Pretty-print logs instead of JSON | false |
| BASIC_AUTH | --basic-auth <username:password> |
Enable Basic Auth (username:password) | (empty) |
| BASIC_AUTH_REALM | --basic-auth-realm <string> |
Basic Auth realm name | Restricted |
When Basic Auth is enabled, always run behind HTTPS (or a TLS-terminating reverse proxy). Basic Auth over plain HTTP exposes credentials.
Enable Brotli:
# docker-compose.yml
services:
spa:
image: devforth/spa-to-http:latest
command: --brotliChange compression threshold:
services:
spa:
image: devforth/spa-to-http:latest
command: --brotli --threshold 500Serve on a custom port:
services:
spa:
image: devforth/spa-to-http:latest
command: --port 8082
ports:
- "8082:8082"Ignore cache-control for fixed paths (for example, a service worker):
services:
spa:
image: devforth/spa-to-http:latest
command: --ignore-cache-control-paths "/sw.js"Use --base-path when your SPA is exposed behind a URL prefix (for example, /app) while files stay in the same build directory.
- Empty value becomes
/ - Missing leading slash is added (
app->/app) - Trailing slash is removed (
/app/->/app) - Query strings and fragments are invalid (
/app?a=1,/app#x)
With --base-path /app and --directory /code:
/app->/code/index.html/app/->/code/index.html/app/assets/main.js->/code/assets/main.js/app/route1-> SPA fallback to/code/index.html(when--spais enabled)
Requests outside the base path continue to follow normal root behavior:
/assets/main.js->/code/assets/main.js
When --base-path is set, ignore paths are matched against both:
- Raw incoming request path (for example,
/app/sw.js) - Mapped internal path (for example,
/sw.js)
That means either style works:
services:
spa:
image: devforth/spa-to-http:latest
command: --base-path /app --ignore-cache-control-paths "/sw.js,/app/sw.js"- Getting Started — Install, build, and run
- Deployment — Docker and reverse proxy setup
- Architecture — Project structure and request flow