mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-21 18:04:08 +01:00
* feat: Add RouteErrorBoundary for improved error handling and integrate react-error-boundary package * feat: update error message * fix: correct typo in containerClassName prop in Landing component
92 lines
2 KiB
TypeScript
92 lines
2 KiB
TypeScript
import { createBrowserRouter, Navigate, Outlet } from 'react-router-dom';
|
|
import {
|
|
Login,
|
|
Registration,
|
|
RequestPasswordReset,
|
|
ResetPassword,
|
|
VerifyEmail,
|
|
ApiErrorWatcher,
|
|
} from '~/components/Auth';
|
|
import { AuthContextProvider } from '~/hooks/AuthContext';
|
|
import RouteErrorBoundary from './RouteErrorBoundary';
|
|
import StartupLayout from './Layouts/Startup';
|
|
import LoginLayout from './Layouts/Login';
|
|
import dashboardRoutes from './Dashboard';
|
|
import ShareRoute from './ShareRoute';
|
|
import ChatRoute from './ChatRoute';
|
|
import Search from './Search';
|
|
import Root from './Root';
|
|
|
|
const AuthLayout = () => (
|
|
<AuthContextProvider>
|
|
<Outlet />
|
|
<ApiErrorWatcher />
|
|
</AuthContextProvider>
|
|
);
|
|
|
|
export const router = createBrowserRouter([
|
|
{
|
|
path: 'share/:shareId',
|
|
element: <ShareRoute />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
},
|
|
{
|
|
path: '/',
|
|
element: <StartupLayout />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
children: [
|
|
{
|
|
path: 'register',
|
|
element: <Registration />,
|
|
},
|
|
{
|
|
path: 'forgot-password',
|
|
element: <RequestPasswordReset />,
|
|
},
|
|
{
|
|
path: 'reset-password',
|
|
element: <ResetPassword />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: 'verify',
|
|
element: <VerifyEmail />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
},
|
|
{
|
|
element: <AuthLayout />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
children: [
|
|
{
|
|
path: '/',
|
|
element: <LoginLayout />,
|
|
children: [
|
|
{
|
|
path: 'login',
|
|
element: <Login />,
|
|
},
|
|
],
|
|
},
|
|
dashboardRoutes,
|
|
{
|
|
path: '/',
|
|
element: <Root />,
|
|
children: [
|
|
{
|
|
index: true,
|
|
element: <Navigate to="/c/new" replace={true} />,
|
|
},
|
|
{
|
|
path: 'c/:conversationId?',
|
|
element: <ChatRoute />,
|
|
},
|
|
{
|
|
path: 'search',
|
|
element: <Search />,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
]);
|