Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: persist SSO auth token on root route loader (#12784)

Levi4b50b8c579ce
diff --git a/web/src/routes.tsx b/web/src/routes.tsx
index ab05987c92..198b95f496 100644
--- a/web/src/routes.tsx
+++ b/web/src/routes.tsx
@@ -1,7 +1,8 @@
import { lazy, memo, Suspense } from 'react';
-import { createBrowserRouter, Navigate, type RouteObject } from 'react-router';
+import { createBrowserRouter, Navigate, redirect, type RouteObject } from 'react-router';
import FallbackComponent from './components/fallback-component';
import { IS_ENTERPRISE } from './pages/admin/utils';
+import authorizationUtil from './utils/authorization-util';
export enum Routes {
Root = '/',
@@ -141,7 +142,16 @@ const routeConfigOptions = [
path: Routes.Root,
layout: false,
Component: () => import('@/layouts/next'),
- wrappers: ['@/wrappers/auth'],
+ loader: ({ request }) => {
+ const url = new URL(request.url);
+ const auth = url.searchParams.get('auth');
+ if (auth) {
+ authorizationUtil.setAuthorization(auth);
+ url.searchParams.delete('auth');
+ return redirect(`${url.pathname}${url.search}`);
+ }
+ return null;
+ },
children: [
{
path: Routes.Root,
diff --git a/web/src/utils/authorization-util.ts b/web/src/utils/authorization-util.ts
index e25e4915f1..328def48de 100644
--- a/web/src/utils/authorization-util.ts
+++ b/web/src/utils/authorization-util.ts
@@ -49,9 +49,7 @@ const storage = {
export const getAuthorization = () => {
const auth = getSearchValue('auth');
- const authorization = auth
- ? 'Bearer ' + auth
- : storage.getAuthorization() || '';
+ const authorization = auth ? auth : storage.getAuthorization() || '';
return authorization;
};