Connect OpenCode Mobile Through a Reverse Proxy or API Prefix
OpenCode Mobile accepts a base URL with a prefix, for example:
https://dev.example.com/apiWith that setting, health and session calls stay under the prefix, such as:
https://dev.example.com/api/global/healthTerminal WebSockets also preserve the prefix and switch to wss: for HTTPS endpoints.
When to use a path prefix
Section titled “When to use a path prefix”/serves a web application instead of the OpenCode API- A proxy mounts OpenCode under
/apior another subpath - The app reports that the server returned HTML, a JSON parse error, 404, or another non-API response
Do not append /api blindly. Verify the resulting /global/health endpoint first.
Proxy requirements
Section titled “Proxy requirements”A reverse proxy must forward ordinary HTTP requests, server-sent events (SSE), and terminal WebSockets. If streaming or WebSocket upgrades are dropped, tasks appear to stall or the terminal fails while the browser UI still works.
Before you publish
Section titled “Before you publish”Read the remote-access security model first. Use HTTPS, require OpenCode authentication, and avoid exposing an unauthenticated server.
For other routes, return to the remote-access overview or use the troubleshooting checklist.