| 179 | } |
| 180 | |
| 181 | function showHelp() { |
| 182 | console.log(` |
| 183 | Combined static file server + reverse proxy. |
| 184 | |
| 185 | USAGE: |
| 186 | node scripts/static-server.mjs [options] |
| 187 | |
| 188 | OPTIONS: |
| 189 | -p, --port <port> Port to bind (default: 3001) |
| 190 | -H, --host <host> Hostname to bind (default: :: dual-stack) |
| 191 | -d, --dir <dir> Directory to serve (default: build) |
| 192 | -r, --route <prefix=url> Proxy <prefix> (and subpaths) to <url>; |
| 193 | may be repeated. WebSockets supported. |
| 194 | --session-api-key <key> Inject session API key into index.html so the |
| 195 | pre-built frontend authenticates to agent-server |
| 196 | without needing VITE_SESSION_API_KEY baked in. |
| 197 | --auth-required Inject authRequired flag into index.html so the |
| 198 | pre-built frontend shows the API key entry screen |
| 199 | (public mode) without VITE_AUTH_REQUIRED baked in. |
| 200 | --runtime-services-info <json> |
| 201 | Inject a JSON description of the local runtime |
| 202 | services into index.html so the pre-built |
| 203 | frontend can populate the agent's |
| 204 | <RUNTIME_SERVICES> system-prompt block without |
| 205 | VITE_RUNTIME_SERVICES_INFO baked in. |
| 206 | --lock-to-cloud <cloud-url> Lock backend setup to a single OpenHands Cloud |
| 207 | URL. Hides manual/local backend setup and the |
| 208 | custom Cloud URL field in the pre-built frontend. |
| 209 | --base-path <path> Mount the SPA under <path> (default: /). |
| 210 | For example, --base-path /canvas serves |
| 211 | index.html and assets under /canvas. |
| 212 | --reject-prefix <prefix> Return 503 for requests matching <prefix> |
| 213 | instead of SPA-fallbacking to index.html; |
| 214 | may be repeated. Useful in --frontend-only |
| 215 | mode to cleanly reject API paths. |
| 216 | -h, --help Show this help |
| 217 | |
| 218 | ROUTING: |
| 219 | • Routes are matched by longest prefix first (most-specific wins). |
| 220 | • Reject prefixes are checked before SPA fallback — matching requests |
| 221 | get 503 immediately. |
| 222 | • Anything that does not match a route or reject prefix is served |
| 223 | from --dir. |
| 224 | • Unknown paths fall back to index.html (SPA mode), unless they look |
| 225 | like an asset request (have a known file extension), in which case |
| 226 | a 404 is returned. |
| 227 | `); |
| 228 | } |
| 229 | |
| 230 | // ───────────────────────────────────────────────────────────────────────────── |
| 231 | // Runtime config injection |