Fix the dns issue

This commit is contained in:
2025-09-08 10:40:11 +02:00
parent eee6928a2d
commit a1eccb0a56

View File

@@ -61,24 +61,21 @@ fi
: "${MEILI_KEY:=${MEILI_MASTER_KEY:-}}" : "${MEILI_KEY:=${MEILI_MASTER_KEY:-}}"
: "${OPENWEBUI_URL:=http://localhost:3003}" : "${OPENWEBUI_URL:=http://localhost:3003}"
: "${OPENWEBUI_URL_HOST:=}"
: "${OPENWEBUI_API_KEY:=}" : "${OPENWEBUI_API_KEY:=}"
# Resolve a working OpenWebUI base URL (fallback from host.docker.internal -> localhost) # Resolve a working OpenWebUI base URL (fallback from host.docker.internal -> localhost)
_owui_url() { _owui_url() {
local u="${OPENWEBUI_URL:-http://localhost:3003}" # If a host-only override is provided, prefer it unconditionally
# quick health check local host_u="${OPENWEBUI_URL_HOST:-}"
local code if [ -n "$host_u" ]; then
code=$(curl -sS -o /dev/null -w "%{http_code}" "$u/api/health" || true) echo "$host_u"
if [ "$code" != "200" ]; then return
if [[ "$u" == *host.docker.internal* ]]; then
local alt="${u/host.docker.internal/localhost}"
code=$(curl -sS -o /dev/null -w "%{http_code}" "$alt/api/health" || true)
if [ "$code" = "200" ]; then
echo "$alt"
return
fi
fi
fi fi
# Otherwise use OPENWEBUI_URL (defaulting to localhost), and rewrite
# host.docker.internal -> localhost so it always resolves on the host
local u="${OPENWEBUI_URL:-http://localhost:3003}"
u="${u//host.docker.internal/localhost}"
echo "$u" echo "$u"
} }