@@ -8,7 +8,7 @@ export default function VatsimCallback() {
88 const hasSubmitted = useRef ( false ) ;
99
1010 useEffect ( ( ) => {
11- if ( hasSubmitted . current ) return ; // prevent double-run in React StrictMode
11+ if ( hasSubmitted . current ) return ;
1212 hasSubmitted . current = true ;
1313
1414 const run = async ( ) => {
@@ -20,25 +20,29 @@ export default function VatsimCallback() {
2020 return ;
2121 }
2222 try {
23- const res = await fetch ( `${ import . meta. env . VITE_SERVER_URL } /api/auth/vatsim/exchange` , {
24- method : 'POST' ,
25- headers : { 'Content-Type' : 'application/json' } ,
26- credentials : 'include' ,
27- body : JSON . stringify ( { code, state } )
28- } ) ;
23+ const res = await fetch (
24+ `${ import . meta. env . VITE_SERVER_URL } /api/auth/vatsim/exchange` ,
25+ {
26+ method : 'POST' ,
27+ headers : { 'Content-Type' : 'application/json' } ,
28+ credentials : 'include' ,
29+ body : JSON . stringify ( { code, state } ) ,
30+ }
31+ ) ;
2932 if ( ! res . ok ) {
3033 navigate ( '/settings?error=vatsim_link_failed' ) ;
3134 return ;
3235 }
3336 await refreshUser ( ) ;
34- // Clean up query params to avoid accidental re-exchange on back/refresh
3537 try {
3638 const url = new URL ( window . location . href ) ;
3739 url . search = '' ;
3840 window . history . replaceState ( { } , '' , url . toString ( ) ) ;
39- } catch { }
41+ } catch {
42+ // If URL API is not supported, do nothing
43+ }
4044 navigate ( '/settings?vatsim_linked=true' ) ;
41- } catch ( err ) {
45+ } catch {
4246 navigate ( '/settings?error=vatsim_link_failed' ) ;
4347 }
4448 } ;
0 commit comments