File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff 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 = '/' ;
You can’t perform that action at this time.
0 commit comments