Skip to content

Commit a98bc47

Browse files
committed
fix: Clean OAuth callback params before environment switch
1 parent 46776c4 commit a98bc47

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/components/TopBar/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,18 @@ export const TopBar: React.FC<TopBarProps> = ({
8787
localStorage.setItem('environment-switching', 'true');
8888
console.log(`✅ Environment set to: ${targetEnv}`);
8989

90-
// Step 5: Force full page reload to re-initialize with new environment
90+
// Step 5: Clean URL to remove any OAuth callback parameters before reload
91+
// This prevents the app from trying to process an OAuth code from the old environment
92+
console.log('🧹 Cleaning URL parameters...');
93+
const cleanUrl = window.location.origin + '/';
94+
95+
// Replace the current history entry to remove OAuth params
96+
if (window.location.href !== cleanUrl) {
97+
window.history.replaceState({}, '', cleanUrl);
98+
console.log('✅ URL cleaned:', cleanUrl);
99+
}
100+
101+
// Step 6: Force full page reload to re-initialize with new environment
91102
// This ensures we don't try to read from localStorage - the reload will handle everything
92103
console.log('🔄 Reloading page...');
93104
window.location.href = '/';

0 commit comments

Comments
 (0)