fix: replace per-path proxy with cookie-based catch-all routing
The /session/{id} URL prefix collided with OpenCode's internal
/session/{slug} SPA routes, causing a blank page. Now /c/{id} is
a thin entry point that sets a session cookie and redirects to /,
where the SPA loads at root with its router working correctly.
This also replaces ~50 individual per-path proxy route handlers
with a single /{path:path} catch-all, and simplifies the Caddyfile
from ~180 lines to ~17.
This commit is contained in:
183
nginx/Caddyfile
183
nginx/Caddyfile
@@ -2,187 +2,16 @@
|
||||
# Using HTTP for local development (no SSL warnings)
|
||||
|
||||
# Main web interface - HTTP only for development
|
||||
http://localhost {
|
||||
# API endpoints for session management
|
||||
:80 {
|
||||
# API endpoints for session management (strip /api prefix)
|
||||
handle /api/* {
|
||||
uri strip_prefix /api
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# OpenCode internal session API (without session_id in path)
|
||||
# Must be BEFORE /session/{session_id}* to match first
|
||||
handle /session {
|
||||
# Everything else goes to session-manager (handles /c/{id} entry
|
||||
# point and cookie-based proxy to OpenCode containers)
|
||||
handle {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# Session-specific routing - proxy to session manager for dynamic routing
|
||||
handle /session/{session_id}* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# OpenCode SPA runtime requests - route based on session cookie
|
||||
handle /global/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /assets/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /provider/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /provider {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /project {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /path {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /find/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /file {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /file/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# Additional OpenCode API endpoints for root-path operation
|
||||
handle /agent {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /agent/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /config {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /config/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /model {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /model/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /thread/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /chat/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /tree {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /tree/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /conversation {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /conversation/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /project/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# OpenCode communication endpoints for message sending
|
||||
handle /command {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /command/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /mcp {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /mcp/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /lsp {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /lsp/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /vcs {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /vcs/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /permission {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /permission/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /question {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /question/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /event {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /event/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /status {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
handle /status/* {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# Health check
|
||||
handle /health {
|
||||
reverse_proxy session-manager:8000
|
||||
}
|
||||
|
||||
# Static files and main interface (fallback)
|
||||
handle /* {
|
||||
try_files {path} {path}/ /index.html
|
||||
file_server
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user