chore: redirect to APP_URL from superadmin

This commit is contained in:
Abhishek Kumar 2026-07-17 11:32:45 +05:30
parent 23956ac55c
commit 1aa4937b22
2 changed files with 7 additions and 6 deletions

View file

@ -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

View file

@ -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';