Implementation:FlowiseAI Flowise DefaultRedirect
| Knowledge Sources | |
|---|---|
| Domains | Routing, Authorization |
| Last Updated | 2026-02-12 07:00 GMT |
Overview
DefaultRedirect is a React component that determines and renders the first accessible view for the current user based on their permissions and feature flags, preventing 403 errors on the default landing page.
Description
The DefaultRedirect component implements a smart landing page strategy. It defines an ordered list of route-component pairs (matching the sidebar menu order from dashboard.js) and iterates through them, checking each route's required permission and display flag using the useAuth hook. The first route that passes both checks is rendered directly as the landing component. For unauthenticated users, it renders the Login page. For open-source deployments or global administrators, it defaults to Chatflows. If no accessible route is found (an edge case), it renders the Unauthorized page.
Usage
Use this component as the element for the root (/) path in the React Router configuration. It replaces a simple redirect to /chatflows with a permission-aware redirect that ensures every user lands on a page they are authorized to view.
Code Reference
Source Location
- Repository: FlowiseAI Flowise
- File: packages/ui/src/routes/DefaultRedirect.jsx
- Lines: 1-100
Signature
export const DefaultRedirect = () => { ... }
Import
import { DefaultRedirect } from '@/routes/DefaultRedirect'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | - | - | This component accepts no props. It reads authentication state, permissions, and feature flags from Redux and ConfigContext internally. |
Outputs
| Name | Type | Description |
|---|---|---|
| JSX | React.ReactElement | Renders the first accessible view component based on user permissions. Falls back to Login (unauthenticated), Chatflows (open-source/global admin), or Unauthorized (no permissions). |
Route Priority Order
The component checks routes in this order and renders the first accessible one:
| Priority | Component | Permission | Display Flag |
|---|---|---|---|
| 1 | Chatflows | chatflows:view | - |
| 2 | Agentflows | agentflows:view | - |
| 3 | Executions | executions:view | - |
| 4 | Assistants | assistants:view | - |
| 5 | Marketplaces | templates:marketplace,templates:custom | - |
| 6 | Tools | tools:view | - |
| 7 | Credentials | credentials:view | - |
| 8 | Variables | variables:view | - |
| 9 | APIKey | apikeys:view | - |
| 10 | Documents | documentStores:view | - |
| 11 | EvalDatasets | datasets:view | feat:datasets |
| 12 | Evaluators | evaluators:view | feat:evaluators |
| 13 | EvalEvaluation | evaluations:view | feat:evaluations |
| 14 | SSOConfig | sso:manage | feat:sso-config |
| 15 | RolesPage | roles:manage | feat:roles |
| 16 | UsersPage | users:manage | feat:users |
| 17 | Workspaces | workspace:view | feat:workspaces |
| 18 | LoginActivityPage | loginActivity:view | feat:login-activity |
| 19 | Logs | logs:view | feat:logs |
| 20 | Account | (none) | feat:account |
Usage Examples
Basic Usage
import { DefaultRedirect } from '@/routes/DefaultRedirect'
const MainRoutes = {
path: '/',
element: <MainLayout />,
children: [
{
path: '/',
element: <DefaultRedirect />
},
// ... other routes
]
}