mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-19 11:08:37 +00:00
fix: add dynamic route for custom OAuth provider callbacks (#2911)
Custom OAuth providers redirect to /oauth/{slug} after authorization,
but only hardcoded provider routes (github, discord, oidc, linuxdo)
existed in the frontend router, causing a 404 for custom providers.
This commit is contained in:
@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { lazy, Suspense, useContext, useMemo } from 'react';
|
import React, { lazy, Suspense, useContext, useMemo } from 'react';
|
||||||
import { Route, Routes, useLocation } from 'react-router-dom';
|
import { Route, Routes, useLocation, useParams } from 'react-router-dom';
|
||||||
import Loading from './components/common/ui/Loading';
|
import Loading from './components/common/ui/Loading';
|
||||||
import User from './pages/User';
|
import User from './pages/User';
|
||||||
import { AuthRedirect, PrivateRoute, AdminRoute } from './helpers';
|
import { AuthRedirect, PrivateRoute, AdminRoute } from './helpers';
|
||||||
@@ -56,6 +56,11 @@ const About = lazy(() => import('./pages/About'));
|
|||||||
const UserAgreement = lazy(() => import('./pages/UserAgreement'));
|
const UserAgreement = lazy(() => import('./pages/UserAgreement'));
|
||||||
const PrivacyPolicy = lazy(() => import('./pages/PrivacyPolicy'));
|
const PrivacyPolicy = lazy(() => import('./pages/PrivacyPolicy'));
|
||||||
|
|
||||||
|
function DynamicOAuth2Callback() {
|
||||||
|
const { provider } = useParams();
|
||||||
|
return <OAuth2Callback type={provider} />;
|
||||||
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [statusState] = useContext(StatusContext);
|
const [statusState] = useContext(StatusContext);
|
||||||
@@ -234,6 +239,14 @@ function App() {
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path='/oauth/:provider'
|
||||||
|
element={
|
||||||
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
|
<DynamicOAuth2Callback />
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/setting'
|
path='/console/setting'
|
||||||
element={
|
element={
|
||||||
|
|||||||
Reference in New Issue
Block a user