Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix(auth): derive NEXTAUTH_URL from request host instead of pinning l… (#1355)

Aman Agarwal8adf21c8f952
diff --git a/src/client/package-lock.json b/src/client/package-lock.json
index 923ae403..96053a79 100644
--- a/src/client/package-lock.json
+++ b/src/client/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "openlit",
- "version": "1.23.0",
+ "version": "1.24.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openlit",
- "version": "1.23.0",
+ "version": "1.24.0",
"dependencies": {
"@ai-sdk/anthropic": "^3.0.6",
"@ai-sdk/cohere": "^3.0.3",
diff --git a/src/client/package.json b/src/client/package.json
index a56e7ea5..43de69c7 100644
--- a/src/client/package.json
+++ b/src/client/package.json
@@ -1,6 +1,6 @@
{
"name": "openlit",
- "version": "1.23.0",
+ "version": "1.24.0",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/src/client/scripts/entrypoint.sh b/src/client/scripts/entrypoint.sh
index 32a18fd4..429be762 100644
--- a/src/client/scripts/entrypoint.sh
+++ b/src/client/scripts/entrypoint.sh
@@ -25,10 +25,14 @@ else
echo "WARNING: /etc/environment is not writable; NEXTAUTH_SECRET will not be persisted there." >&2
fi
-if [ -z "${NEXTAUTH_URL}" ]; then
- export NEXTAUTH_URL="http://localhost:${DOCKER_PORT:-3000}"
+# Do NOT pin NEXTAUTH_URL to localhost. When it is unset, NextAuth derives the
+# origin from the incoming request host (and X-Forwarded-* behind a proxy), so
+# the app works on any URL (localhost, LoadBalancer, Ingress) with no config.
+# Only export it when the operator explicitly set it, which is required for
+# OAuth providers whose redirect URIs must match a fixed public URL.
+if [ -n "${NEXTAUTH_URL}" ]; then
+ echo "NEXTAUTH_URL=${NEXTAUTH_URL}" >> /etc/environment
fi
-echo "NEXTAUTH_URL=${NEXTAUTH_URL}" >> /etc/environment
echo "SQLITE_DATABASE_URL=${SQLITE_DATABASE_URL:-file:../data/data.db}" >> /etc/environment
echo "PATH=./node_modules/.bin:$PATH" >> /etc/environment