Skip to content

Commit ac01c5b

Browse files
jamiepineclaude
andcommitted
fix opencode proxy path prefix
Route is registered at absolute path `/api/opencode/{port}/{*path}` on the protected router, not nested under `/api`, so the handler sees the full path including `/api/`. Accept both prefixes for compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fb5c0f3 commit ac01c5b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/api/opencode_proxy.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ pub(super) async fn opencode_proxy(request: Request) -> Response {
4040
let uri = request.uri().clone();
4141
let path = uri.path();
4242

43-
// Parse port and remainder from the path.
44-
// The route is nested under `/api` via Router::nest, so Axum strips that
45-
// prefix before the handler runs. We see `/opencode/{port}/{rest...}`.
46-
let after_prefix = match path.strip_prefix("/opencode/") {
43+
// Parse port and remainder from the path. The route is registered at
44+
// the absolute path `/api/opencode/{port}/{*path}` on the protected
45+
// router (not inside the `/api` nest), so the handler sees the full
46+
// path including the `/api/` prefix. Also accept `/opencode/` for
47+
// defensive compatibility in case the route is ever moved back inside
48+
// the nest.
49+
let after_prefix = match path
50+
.strip_prefix("/api/opencode/")
51+
.or_else(|| path.strip_prefix("/opencode/"))
52+
{
4753
Some(rest) => rest,
4854
None => return (StatusCode::BAD_REQUEST, "invalid proxy path").into_response(),
4955
};

0 commit comments

Comments
 (0)