Skip to content

Open-source status page, incident response and uptime monitoring

fix: hide telegram qr code when self-hosting with no redis (#2535)

Max55c2881461ce
diff --git a/.env.docker.example b/.env.docker.example
index e248359b6..19c102bdb 100644
--- a/.env.docker.example
+++ b/.env.docker.example
@@ -61,6 +61,10 @@ AUTH_SECRET=your-random-secret-here-min-32-chars
# [REQUIRED] Self-hosted mode - enables magic link authentication
# Set to "true" to allow email login without OAuth
+# Note: NEXT_PUBLIC_SELF_HOST is the client-side build-time version of this flag,
+# baked into the Docker image at build time (see apps/dashboard/Dockerfile).
+# It controls UI behavior like the Telegram connection flow (QR vs manual input),
+# and cannot be changed via this runtime config file.
SELF_HOST="true"
# GitHub OAuth (optional)
diff --git a/apps/dashboard/Dockerfile b/apps/dashboard/Dockerfile
index 6c2d045a2..e991e7143 100644
--- a/apps/dashboard/Dockerfile
+++ b/apps/dashboard/Dockerfile
@@ -22,6 +22,7 @@ ENV \
UPSTASH_REDIS_REST_URL="https://test.upstash.io" \
UNKEY_TOKEN="test" \
SELF_HOST="true" \
+ NEXT_PUBLIC_SELF_HOST="true" \
UNKEY_API_ID="test" \
STRIPE_SECRET_KEY="test" \
NEXT_PUBLIC_OPENPANEL_CLIENT_ID="test" \
diff --git a/apps/dashboard/dofigen.lock b/apps/dashboard/dofigen.lock
index 16e94a743..a7c7bbd2e 100644
--- a/apps/dashboard/dofigen.lock
+++ b/apps/dashboard/dofigen.lock
@@ -23,6 +23,7 @@ effective: |
UPSTASH_REDIS_REST_URL: https://test.upstash.io
UNKEY_TOKEN: test
SELF_HOST: 'true'
+ NEXT_PUBLIC_SELF_HOST: 'true'
UNKEY_API_ID: test
STRIPE_SECRET_KEY: test
NEXT_PUBLIC_OPENPANEL_CLIENT_ID: test
@@ -123,6 +124,7 @@ resources:
STRIPE_SECRET_KEY: test
AUTH_SECRET: build-time-placeholder-min-32-chars-long
SELF_HOST: "true"
+ NEXT_PUBLIC_SELF_HOST: "true"
run:
- corepack enable
- pnpm install --frozen-lockfile
diff --git a/apps/dashboard/dofigen.yml b/apps/dashboard/dofigen.yml
index 0fca0805f..e2c1bad44 100644
--- a/apps/dashboard/dofigen.yml
+++ b/apps/dashboard/dofigen.yml
@@ -28,6 +28,7 @@ builders:
STRIPE_SECRET_KEY: test
AUTH_SECRET: build-time-placeholder-min-32-chars-long
SELF_HOST: "true"
+ NEXT_PUBLIC_SELF_HOST: "true"
run:
- corepack enable
- pnpm install --frozen-lockfile
diff --git a/apps/dashboard/src/components/forms/components/telegram-connection-flow.tsx b/apps/dashboard/src/components/forms/components/telegram-connection-flow.tsx
index 93b3a53b8..6a465a803 100644
--- a/apps/dashboard/src/components/forms/components/telegram-connection-flow.tsx
+++ b/apps/dashboard/src/components/forms/components/telegram-connection-flow.tsx
@@ -37,6 +37,21 @@ export function TelegramConnectionFlow({
confirmPrivateChat,
} = useTelegramConnection({ form, mode });
+ // Check build-time env var for deployment type
+ const isSelfHosted = process.env.NEXT_PUBLIC_SELF_HOST === "true";
+ const redisAvailable = tokenData?.redisAvailable === true;
+
+ // Biased loading behavior:
+ // - Self-hosted: Hide QR during loading (conservative, prevents flash)
+ // - Cloud: Show QR during loading (optimistic, better UX)
+ // After loading: always check actual redisAvailable value
+ if (
+ (isSelfHosted && isTokenLoading) ||
+ (!isTokenLoading && !redisAvailable)
+ ) {
+ return <TelegramManualInput form={form} />;
+ }
+
return (
<Tabs
value={mode ?? "qr"}
@@ -53,7 +68,7 @@ export function TelegramConnectionFlow({
<TabsContent value="qr">
<TelegramQRConnection
form={form}
- token={tokenData?.token}
+ token={tokenData?.token ?? undefined}
isLoading={isTokenLoading}
isPolling={isPolling}
flowStep={flowStep}
diff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.ts
index 771c417cf..e40c63a45 100644
--- a/packages/api/src/router/notification.ts
+++ b/packages/api/src/router/notification.ts
@@ -323,11 +323,17 @@ export const notificationRouter = createTRPCRouter({
const randomId = nanoid(12);
const EXPIRY = 1800; // 30 minutes
- await redis.set(`telegram:workspace_token:${workspaceId}`, randomId, {
- ex: EXPIRY,
- });
-
- return { token: randomId };
+ try {
+ await redis.set(`telegram:workspace_token:${workspaceId}`, randomId, {
+ ex: EXPIRY,
+ });
+ return { token: randomId, redisAvailable: true };
+ } catch (error) {
+ // Redis unavailable (e.g., self-hosted without Redis)
+ // Return null token to signal frontend to use manual setup only
+ console.warn("Redis unavailable for Telegram token storage:", error);
+ return { token: null, redisAvailable: false };
+ }
}),
getTelegramUpdates: protectedProcedure