You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for running OpenCode behind a reverse proxy with a configurable base path prefix (e.g., /myapp/).
- Adds --base-path CLI option, OPENCODE_BASE_PATH env var, and server.basePath config
- Rewrites HTML/JS/CSS responses at runtime to include the base path
- Wraps history.pushState/replaceState to prepend base path to URLs
Copy file name to clipboardExpand all lines: README.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,27 @@ If you're interested in contributing to OpenCode, please read our [contributing
96
96
97
97
If you are working on a project that's related to OpenCode and is using "opencode" as a part of its name; for example, "opencode-dashboard" or "opencode-mobile", please add a note to your README to clarify that it is not built by the OpenCode team and is not affiliated with us in any way.
98
98
99
+
### Running Behind a Reverse Proxy
100
+
101
+
OpenCode supports running behind a reverse proxy with a base path prefix:
102
+
103
+
```bash
104
+
# CLI flag
105
+
opencode web --base-path /my-prefix/
106
+
107
+
# Environment variable
108
+
OPENCODE_BASE_PATH=/my-prefix/ opencode web
109
+
110
+
# Config file (opencode.json)
111
+
{
112
+
"server": {
113
+
"basePath": "/my-prefix/"
114
+
}
115
+
}
116
+
```
117
+
118
+
This is useful for deploying behind a reverse proxy with path-based routing (e.g., Kubernetes Ingress, nginx, traefik).
0 commit comments