Hermes Agent commited on
Commit
d8fa935
·
1 Parent(s): 6895258

Fix OmniRoute reverse-proxy routing: strip /omniroute prefix when proxying to port 20128 and handle RSC/dashboard fallbacks

Browse files
Files changed (2) hide show
  1. gateway/main.py +8 -1
  2. gateway/omniroute.py +2 -1
gateway/main.py CHANGED
@@ -83,6 +83,13 @@ async def route_catch_all(path: str, request: Request):
83
  return await proxy_http_request(f"http://127.0.0.1:{JELLYFIN_PORT}/{path}", request, default_prefix="/jellyfin", extra_headers={"X-Forwarded-Prefix": "/jellyfin"})
84
  elif "/tg_stream" in referer or req_path.startswith("/tg_stream"):
85
  return await proxy_http_request(f"http://127.0.0.1:{TG_PORT}/{path}", request, default_prefix="/tg_stream")
 
 
 
 
 
 
 
86
 
87
- # Default all root traffic to Open WebUI!
88
  return await proxy_http_request(f"http://127.0.0.1:{WEBUI_PORT}/{path}", request, html_fixup=fixup_webui_html)
 
83
  return await proxy_http_request(f"http://127.0.0.1:{JELLYFIN_PORT}/{path}", request, default_prefix="/jellyfin", extra_headers={"X-Forwarded-Prefix": "/jellyfin"})
84
  elif "/tg_stream" in referer or req_path.startswith("/tg_stream"):
85
  return await proxy_http_request(f"http://127.0.0.1:{TG_PORT}/{path}", request, default_prefix="/tg_stream")
86
+ elif "/omniroute" in referer or "_rsc" in request.query_params or req_path in ("/dashboard", "/status", "/settings", "/combos", "/providers", "/logs", "/api-keys"):
87
+ extra = {
88
+ "Host": f"127.0.0.1:{OMNIROUTE_PORT}",
89
+ "X-Forwarded-Host": f"127.0.0.1:{OMNIROUTE_PORT}",
90
+ "X-Forwarded-Proto": "http"
91
+ }
92
+ return await proxy_http_request(f"http://127.0.0.1:{OMNIROUTE_PORT}/{path}", request, default_prefix="/omniroute", extra_headers=extra)
93
 
94
+ # Default all remaining root traffic to Open WebUI
95
  return await proxy_http_request(f"http://127.0.0.1:{WEBUI_PORT}/{path}", request, html_fixup=fixup_webui_html)
gateway/omniroute.py CHANGED
@@ -34,7 +34,8 @@ async def omniroute_main_route(request: Request, path: str = ""):
34
  "X-Forwarded-Host": f"127.0.0.1:{OMNIROUTE_PORT}",
35
  "X-Forwarded-Proto": "http"
36
  }
37
- target = f"http://127.0.0.1:{OMNIROUTE_PORT}/omniroute/{path}" if path else f"http://127.0.0.1:{OMNIROUTE_PORT}/omniroute"
 
38
  return await proxy_http_request(
39
  target,
40
  request,
 
34
  "X-Forwarded-Host": f"127.0.0.1:{OMNIROUTE_PORT}",
35
  "X-Forwarded-Proto": "http"
36
  }
37
+ # Strip /omniroute prefix when proxying to OmniRoute backend on port 20128
38
+ target = f"http://127.0.0.1:{OMNIROUTE_PORT}/{path}" if path else f"http://127.0.0.1:{OMNIROUTE_PORT}/"
39
  return await proxy_http_request(
40
  target,
41
  request,