Skip to content

[Bug]: Authorization redirects fail using createBrowserRouter loaders #9332

Closed Answered by Ces-D
Ces-D asked this question in Q&A
Discussion options

You must be logged in to vote

I figured it out. The issue was with circular loaders redirecting to each other. There is no error here.

export const authorizationBrowserRouterObjects: RouteObject[] = [
  {
    path: AuthRoutes.LOGIN, element: <LoginView />,
    loader: () => browserRouterAuthLoader({ authRequired: false, to: MiscRoutes.HOME })
  }
]

export const miscellaneousBrowserRouterObjects: RouteObject[] = [
  {
    path: MiscRoutes.HOME, element: <HomeView />,
    loader: () => browserRouterAuthLoader({ authRequired: true, to: AuthRoutes.LOGIN })
  }
]

/** A loader function that runs before the route transition begins. Handles redirecting 
 * if authorization conditions are not met.
 * 
 * Only provide `to` if…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AMoktar
Comment options

Answer selected by Ces-D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #9329 on September 23, 2022 12:03.