wire spec-driven auth: remove VITE_AUTH_BASE_URL, reorder providers
- main.jsx: remove VITE_AUTH_BASE_URL env var; add AppContent that reads authConfig from useAppContext() and passes to AuthProvider; reorder: AppProvider -> AuthProvider -> BrowserRouter - sync react-openapi: AuthConfig type, extractAuthConfig, loading fix - sync react-auth: authConfig prop, config-driven paths, server logout
This commit is contained in:
28
src/main.jsx
28
src/main.jsx
@@ -15,7 +15,7 @@ import {
|
||||
import Home from './Home';
|
||||
import FetchRequests from './FetchRequest/FetchRequestCreate';
|
||||
import FetchRequestDetail from './FetchRequest/FetchRequestDetail';
|
||||
import { AppProvider, Admin, ProfileRoutes } from '../react-openapi';
|
||||
import { AppProvider, useAppContext, Admin, ProfileRoutes } from '../react-openapi';
|
||||
import { AuthProvider, AuthPage, useAuth, ProfileCreate, ProfileEdit, ProfileView } from "../react-auth";
|
||||
import Header from './Header';
|
||||
import Footer from './Footer';
|
||||
@@ -27,8 +27,6 @@ const queryClient = new QueryClient();
|
||||
const rootElement = document.getElementById('root');
|
||||
const root = createRoot(rootElement);
|
||||
|
||||
const AUTH_BASE = import.meta.env.VITE_AUTH_BASE_URL;
|
||||
|
||||
// Wire profile components from react-auth into the spec-driven admin
|
||||
specConfiguration.profileComponents = {
|
||||
create: ProfileCreate,
|
||||
@@ -81,11 +79,12 @@ const routerMapping = [
|
||||
{ path: "/profile/*", component: ProfileRoutes, headerTitle: "Profile" },
|
||||
];
|
||||
|
||||
root.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AppProvider specConfiguration={specConfiguration}>
|
||||
<BrowserRouter>
|
||||
<AuthProvider authBaseUrl={AUTH_BASE}>
|
||||
/** Reads authConfig from AppProvider context and passes it to AuthProvider. */
|
||||
function AppContent() {
|
||||
const { authConfig } = useAppContext();
|
||||
return (
|
||||
<AuthProvider authConfig={authConfig}>
|
||||
<BrowserRouter>
|
||||
<AppTheme>
|
||||
<CssBaseline enableColorScheme />
|
||||
<Header routerMapping={routerMapping} />
|
||||
@@ -106,8 +105,15 @@ root.render(
|
||||
|
||||
<Footer />
|
||||
</AppTheme>
|
||||
</AuthProvider>
|
||||
</BrowserRouter>
|
||||
</BrowserRouter>
|
||||
</AuthProvider>
|
||||
);
|
||||
}
|
||||
|
||||
root.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AppProvider specConfiguration={specConfiguration}>
|
||||
<AppContent />
|
||||
</AppProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
);
|
||||
Reference in New Issue
Block a user