Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible interference with AuthProvider and react-router route loader #1055

Open
cscottrun opened this issue Feb 26, 2024 · 0 comments
Open

Comments

@cscottrun
Copy link

cscottrun commented Feb 26, 2024

It appears there may be some interference between my oidc-react AuthProvider and the use of the new route loader with react-router v.6.
To provide context, the loader provides data to the route element before it renders.
My AuthProvider works completely fine, redirecting to login, when i do not use the loader. But when I do use a loader (for example fetching data for my homepage), then no redirect to login occurs and my app of course fails to get the necessary credentials to render the homepage.
I'm wondering if anyone else has had this experience and what solution could be. Thanks.
Here's an abbreviated version of my code

App.js

`const router = createBrowserRouter([
  {
    id: "root",
    path: "/",
    errorElement: <FullPageError />,
    element: <Authentication />, // < --  this is just my <AuthProvider /> and all the necessary config props. 
    children: [
      {
        element: <LayoutWithProps />,
        children: [
          {
            index: true,
            element: <Applications />,
            loader: getApplications,  // <-- this is the line that messes things up. However it works great if i have an active session.
          }
        ],
      },
    ],
  },
]);

function App() {
  return <RouterProvider router={router} />;
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant