74b5d0dc8c
Add API proxy endpoint so users can access running tool instances
through the backend API instead of internal Docker network.
Backend:
- Add container_name field to ToolInstance model
- Create /instances/{id}/proxy/{path:path} endpoint with ownership checks
- Proxy HTTP requests to containers via docker network using container names
- Support all HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
- Store proxy URL in instance.url instead of localhost
- Add Alembic migration 0007 for container_name column
- Add get_container_name() utility to docker.py
Frontend:
- Update Open button to use full proxy URL (API_BASE_URL + instance.url)
Closes instance-proxy OpenSpec change.
1.1 KiB
1.1 KiB
1. Backend - Proxy Endpoint
- 1.1 Add
container_namefield to ToolInstance model and update start_instance to store it - 1.2 Create proxy endpoint
/instances/{id}/proxy/{path:path}in tool_instances.py - 1.3 Implement HTTP forwarding using httpx with streaming support
- 1.4 Add ownership check before proxying
- 1.5 Add WebSocket upgrade support for the proxy endpoint
- 1.6 Handle response header forwarding (Content-Type, cookies, etc.)
2. Backend - Instance URL Update
- 2.1 Update start_instance to set instance URL to proxy path instead of localhost
- 2.2 Ensure container_name is captured during start
3. Frontend - Update Instance Links
- 3.1 Update InstanceList "Open" button to use proxy URL
- 3.2 Update SessionsPage "Open" button to use proxy URL
- 3.3 Ensure URLs open in new tab
4. Testing & Quality
- 4.1 Test proxy with code-server instance
- 4.2 Verify WebSocket features work (terminal inside code-server)
- 4.3 Run quality gates (ruff, mypy, typecheck, lint, build)
- 4.4 Deploy and test end-to-end