@@ -16,8 +16,6 @@ import {
1616} from "react" ;
1717import {
1818 Navigate ,
19- useLocation ,
20- useNavigate ,
2119 useSearchParams ,
2220} from "react-router-dom" ;
2321import { useCookies } from "react-cookie" ;
@@ -100,10 +98,22 @@ async function requestJson(
10098 } ) ;
10199
102100 const text = expectJson ? await response . text ( ) : null ;
103- const data = text ? ( JSON . parse ( text ) as Record < string , any > ) : null ;
101+ let data : Record < string , any > | null = null ;
102+
103+ if ( text ) {
104+ try {
105+ data = JSON . parse ( text ) as Record < string , any > ;
106+ } catch {
107+ // Non-JSON response (e.g., HTML error page); keep text for fallback messaging
108+ data = null ;
109+ }
110+ }
104111
105112 if ( ! response . ok ) {
106- const detail = ( data ?. detail as string ) ?? response . statusText ;
113+ const detail =
114+ ( data ?. detail as string ) ??
115+ ( text ? text . slice ( 0 , 200 ) : null ) ??
116+ response . statusText ;
107117 throw new HttpError ( response . status , detail || "Request failed" , data ) ;
108118 }
109119
@@ -228,8 +238,6 @@ export default function OrganizationOnboarding() {
228238 organizationId : organization ?. id ,
229239 } ) ;
230240
231- const location = useLocation ( ) ;
232- const navigate = useNavigate ( ) ;
233241 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
234242
235243 const [ cookies , setCookie , removeCookie ] = useCookies ( [
@@ -241,7 +249,6 @@ export default function OrganizationOnboarding() {
241249 const [ error , setError ] = useState < string | null > ( null ) ;
242250 const [ status , setStatus ] = useState < string | null > ( null ) ;
243251 const [ isBootstrapping , setIsBootstrapping ] = useState ( false ) ;
244- const [ shouldGoToDashboard , setShouldGoToDashboard ] = useState ( false ) ;
245252
246253 const bootstrappedRef = useRef ( false ) ;
247254 const processedOrgRef = useRef < string | null > ( null ) ;
@@ -319,13 +326,18 @@ export default function OrganizationOnboarding() {
319326 }
320327 } , [ removeCookie , signOut ] ) ;
321328
329+ const goToFlows = useCallback ( ( ) => {
330+ console . log ( "[OrganizationOnboarding] Redirecting to /flows" ) ;
331+ window . location . assign ( "/flows" ) ;
332+ } , [ ] ) ;
333+
322334 /**
323335 * Core bootstrap flow:
324336 * - createOrganisation
325337 * - ensureLangflowUser
326338 * - backendLogin
327339 * - persist cookies + storage
328- * - redirect to /dashboard
340+ * - redirect to /flows
329341 */
330342 const bootstrapSession = useCallback ( async ( ) => {
331343 if ( ! isSignedIn || ! organization ?. id || bootstrappedRef . current ) return ;
@@ -367,13 +379,12 @@ export default function OrganizationOnboarding() {
367379
368380 persistSession ( orgToken , ( tokens as any ) ?. refresh_token ?? null , activeOrgId ) ;
369381
370- setStatus ( "Redirecting to dashboard ..." ) ;
382+ setStatus ( "Redirecting to workspace ..." ) ;
371383 console . log (
372- "[OrganizationOnboarding] Redirecting to dashboard with org" ,
384+ "[OrganizationOnboarding] Redirecting to workspace with org" ,
373385 activeOrgId ,
374386 ) ;
375- setShouldGoToDashboard ( true ) ;
376- navigate ( "/dashboard" , { replace : true } ) ;
387+ goToFlows ( ) ;
377388 } catch ( err : any ) {
378389 console . error ( "[OrganizationOnboarding] Failed to bootstrap" , err ) ;
379390 const msg =
@@ -391,10 +402,10 @@ export default function OrganizationOnboarding() {
391402 clearSession ,
392403 getToken ,
393404 isSignedIn ,
394- navigate ,
395405 organization ?. id ,
396406 persistSession ,
397407 user ,
408+ goToFlows ,
398409 ] ) ;
399410
400411 useEffect ( ( ) => {
@@ -422,17 +433,16 @@ export default function OrganizationOnboarding() {
422433 const hasAccessToken = Boolean ( cookies [ LANGFLOW_ACCESS_TOKEN ] ) ;
423434
424435 if ( orgSelected && activeOrgId && hasAccessToken ) {
425- console . log ( "[OrganizationOnboarding] Session already present; routing to /dashboard " , {
436+ console . log ( "[OrganizationOnboarding] Session already present; routing to /flows " , {
426437 activeOrgId,
427438 } ) ;
428- setShouldGoToDashboard ( true ) ;
429- navigate ( "/dashboard" , { replace : true } ) ;
439+ goToFlows ( ) ;
430440 }
431- } , [ cookies , isLoaded , isSignedIn , navigate ] ) ;
441+ } , [ cookies , goToFlows , isLoaded , isSignedIn ] ) ;
432442
433443 /**
434444 * When Clerk redirects back with ?selected=true,
435- * create org + bootstrap session, then go to /dashboard .
445+ * create org + bootstrap session, then go to /flows .
436446 */
437447 useEffect ( ( ) => {
438448 if ( ! isLoaded || ! isSignedIn ) return ;
@@ -495,11 +505,6 @@ export default function OrganizationOnboarding() {
495505 return < Navigate to = "/login" replace /> ;
496506 }
497507
498- if ( shouldGoToDashboard ) {
499- console . log ( "[OrganizationOnboarding] Local redirect flag set; sending to /dashboard" ) ;
500- return < Navigate to = "/dashboard" replace /> ;
501- }
502-
503508 return (
504509 < >
505510 { showLoadingOverlay && (
0 commit comments