From 1aa4937b22fe5f65364912f2331cd02f65564e26 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 17 Jul 2026 11:32:45 +0530 Subject: [PATCH] chore: redirect to APP_URL from superadmin --- ui/.env.example | 3 +++ ui/src/lib/utils.ts | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ui/.env.example b/ui/.env.example index 13d914eb..f95c8c45 100644 --- a/ui/.env.example +++ b/ui/.env.example @@ -1,5 +1,8 @@ BACKEND_URL=http://localhost:8000 NEXT_PUBLIC_BACKEND_URL=http://localhost:8000 +# Base URL of the user-facing app, used for superadmin impersonation redirects +# (defaults to the current origin when unset) +# NEXT_PUBLIC_APP_URL=http://localhost:3010 NEXT_PUBLIC_NODE_ENV=development # form submissions backend # NEXT_PUBLIC_ONBOARDING_API_URL=http://localhost:8001 diff --git a/ui/src/lib/utils.ts b/ui/src/lib/utils.ts index cf7b9ab7..eb7dafd8 100644 --- a/ui/src/lib/utils.ts +++ b/ui/src/lib/utils.ts @@ -190,12 +190,10 @@ export async function impersonateAsSuperadmin(params: { // destination. // --------------------------------------------------------------------------------- - // Determine the base URL that should handle the impersonation cookie. If we are on - // superadmin.dograh.com we want to switch to app.dograh.com. For any other domain - // (e.g. localhost, staging, or already on the app) we just keep the same origin. - const appBaseUrl = window.location.origin.includes('superadmin.') - ? window.location.origin.replace('superadmin.', 'app.') - : window.location.origin; + // Determine the base URL that should handle the impersonation cookie. Configured + // via NEXT_PUBLIC_APP_URL (e.g. https://app.dograh.com); falls back to the current + // origin (e.g. localhost, staging, or already on the app). + const appBaseUrl = process.env.NEXT_PUBLIC_APP_URL || window.location.origin; const finalRedirect = redirectPath ?? '/workflow';