diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index a1347b5a..08d24900 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -10,7 +10,7 @@ import { useCurrentUser, useMasquerade, useLogout } from './hooks/useAuth';
import { useCurrentBusiness } from './hooks/useBusiness';
import { useUpdateBusiness } from './hooks/useBusiness';
import { usePlanFeatures } from './hooks/usePlanFeatures';
-import { setCookie } from './utils/cookies';
+import { setCookie, deleteCookie } from './utils/cookies';
// Import Login Page
const LoginPage = React.lazy(() => import('./pages/LoginPage'));
@@ -463,10 +463,13 @@ const AppContent: React.FC = () => {
return ;
}
- // RULE: Business users on platform subdomain should be redirected to their business subdomain
- if (isBusinessUser && isPlatformDomain && user.business_subdomain) {
- const port = window.location.port ? `:${window.location.port}` : '';
- window.location.href = `${protocol}//${user.business_subdomain}.${baseDomain}${port}/`;
+ // RULE: Non-platform users on platform subdomain should have their session cleared
+ // This handles cases where masquerading changed tokens to a business user
+ if (!isPlatformUser && isPlatformDomain) {
+ deleteCookie('access_token');
+ deleteCookie('refresh_token');
+ localStorage.removeItem('masquerade_stack');
+ window.location.href = '/platform/login';
return ;
}