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