Spaces:
Running
Running
Hermes Agent commited on
Commit ·
c81741b
1
Parent(s): 553f0f7
Configure public base URL env vars and Host/X-Forwarded headers so OmniRoute generates public https URLs for OAuth callbacks
Browse files- entrypoint.sh +12 -3
- gateway/omniroute.py +9 -6
entrypoint.sh
CHANGED
|
@@ -105,10 +105,19 @@ export HOSTNAME="127.0.0.1"
|
|
| 105 |
# Override DATA_DIR to local ext4 to avoid SQLite FUSE I/O errors on HF /data
|
| 106 |
export DATA_DIR="/root/.omniroute"
|
| 107 |
export REDIS_URL="redis://127.0.0.1:6379"
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
export LIVE_WS_ALLOWED_ORIGINS="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
|
|
|
| 112 |
|
| 113 |
# Default admin credentials for OmniRoute
|
| 114 |
export INITIAL_PASSWORD="${INITIAL_PASSWORD:-admin}"
|
|
|
|
| 105 |
# Override DATA_DIR to local ext4 to avoid SQLite FUSE I/O errors on HF /data
|
| 106 |
export DATA_DIR="/root/.omniroute"
|
| 107 |
export REDIS_URL="redis://127.0.0.1:6379"
|
| 108 |
+
|
| 109 |
+
# Public Base URL and Origin settings for OAuth and WebSockets
|
| 110 |
+
export APP_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 111 |
+
export PUBLIC_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 112 |
+
export BASE_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 113 |
+
export NEXT_PUBLIC_BASE_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 114 |
+
export NEXT_PUBLIC_APP_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 115 |
+
export OMNIROUTE_PUBLIC_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 116 |
+
export OMNIROUTE_URL="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 117 |
+
export OMNIROUTE_BASE_PATH=""
|
| 118 |
+
export NEXT_PUBLIC_OMNIROUTE_BASE_PATH=""
|
| 119 |
export LIVE_WS_ALLOWED_ORIGINS="${WEBUI_URL:-https://jishnupg-opencode-cli.hf.space}"
|
| 120 |
+
export OMNIROUTE_AUTO_FREE_FALLBACK_TO_FULL_POOL="true"
|
| 121 |
|
| 122 |
# Default admin credentials for OmniRoute
|
| 123 |
export INITIAL_PASSWORD="${INITIAL_PASSWORD:-admin}"
|
gateway/omniroute.py
CHANGED
|
@@ -31,9 +31,10 @@ router = APIRouter(tags=["OmniRoute"])
|
|
| 31 |
@router.api_route("/omniroute/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
| 32 |
async def omniroute_main_route(request: Request, path: str = ""):
|
| 33 |
extra = {
|
| 34 |
-
"Host":
|
| 35 |
"X-Forwarded-Host": PUBLIC_HOST,
|
| 36 |
-
"X-Forwarded-Proto": "https"
|
|
|
|
| 37 |
}
|
| 38 |
# Strip /omniroute prefix when proxying to OmniRoute backend on port 20128
|
| 39 |
target = f"http://127.0.0.1:{OMNIROUTE_PORT}/{path}" if path else f"http://127.0.0.1:{OMNIROUTE_PORT}/"
|
|
@@ -74,9 +75,10 @@ async def omniroute_monitoring(request: Request, path: str = ""):
|
|
| 74 |
@router.api_route("/omniroute/_next/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
| 75 |
async def omniroute_assets(request: Request, path: str = ""):
|
| 76 |
extra = {
|
| 77 |
-
"Host":
|
| 78 |
"X-Forwarded-Host": PUBLIC_HOST,
|
| 79 |
-
"X-Forwarded-Proto": "https"
|
|
|
|
| 80 |
}
|
| 81 |
target = f"http://127.0.0.1:{OMNIROUTE_PORT}/omniroute/_next/{path}"
|
| 82 |
res = await proxy_http_request(target, request, default_prefix="/omniroute", extra_headers=extra)
|
|
@@ -140,9 +142,10 @@ for p_route in OMNIROUTE_PAGE_ROUTES:
|
|
| 140 |
)
|
| 141 |
async def omniroute_page_handler(request: Request, path: str = ""):
|
| 142 |
extra = {
|
| 143 |
-
"Host":
|
| 144 |
"X-Forwarded-Host": PUBLIC_HOST,
|
| 145 |
-
"X-Forwarded-Proto": "https"
|
|
|
|
| 146 |
}
|
| 147 |
target_path = f"{page_path}/{path}" if path else page_path
|
| 148 |
target = f"http://127.0.0.1:{OMNIROUTE_PORT}{target_path}"
|
|
|
|
| 31 |
@router.api_route("/omniroute/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
| 32 |
async def omniroute_main_route(request: Request, path: str = ""):
|
| 33 |
extra = {
|
| 34 |
+
"Host": PUBLIC_HOST,
|
| 35 |
"X-Forwarded-Host": PUBLIC_HOST,
|
| 36 |
+
"X-Forwarded-Proto": "https",
|
| 37 |
+
"X-Forwarded-Port": "443"
|
| 38 |
}
|
| 39 |
# Strip /omniroute prefix when proxying to OmniRoute backend on port 20128
|
| 40 |
target = f"http://127.0.0.1:{OMNIROUTE_PORT}/{path}" if path else f"http://127.0.0.1:{OMNIROUTE_PORT}/"
|
|
|
|
| 75 |
@router.api_route("/omniroute/_next/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
| 76 |
async def omniroute_assets(request: Request, path: str = ""):
|
| 77 |
extra = {
|
| 78 |
+
"Host": PUBLIC_HOST,
|
| 79 |
"X-Forwarded-Host": PUBLIC_HOST,
|
| 80 |
+
"X-Forwarded-Proto": "https",
|
| 81 |
+
"X-Forwarded-Port": "443"
|
| 82 |
}
|
| 83 |
target = f"http://127.0.0.1:{OMNIROUTE_PORT}/omniroute/_next/{path}"
|
| 84 |
res = await proxy_http_request(target, request, default_prefix="/omniroute", extra_headers=extra)
|
|
|
|
| 142 |
)
|
| 143 |
async def omniroute_page_handler(request: Request, path: str = ""):
|
| 144 |
extra = {
|
| 145 |
+
"Host": PUBLIC_HOST,
|
| 146 |
"X-Forwarded-Host": PUBLIC_HOST,
|
| 147 |
+
"X-Forwarded-Proto": "https",
|
| 148 |
+
"X-Forwarded-Port": "443"
|
| 149 |
}
|
| 150 |
target_path = f"{page_path}/{path}" if path else page_path
|
| 151 |
target = f"http://127.0.0.1:{OMNIROUTE_PORT}{target_path}"
|