Valbar hash-routing för statiska förhandsvisningar
VITE_HASH_ROUTER vid bygget byter till HashRouter så att appen kan köras som en enda statisk HTML-fil utan SPA-rewrites (förhandsvisning/ demo). Standardbygget använder historik-routing precis som förut. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012EQg3rJsrQ1ZNTvkzmQAtt
This commit is contained in:
+7
-3
@@ -2,7 +2,7 @@ import { Toaster } from "@/components/ui/toaster";
|
|||||||
import { Toaster as Sonner } from "@/components/ui/sonner";
|
import { Toaster as Sonner } from "@/components/ui/sonner";
|
||||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
import { BrowserRouter, HashRouter, Routes, Route } from "react-router-dom";
|
||||||
import Index from "./pages/Index";
|
import Index from "./pages/Index";
|
||||||
import NotFound from "./pages/NotFound";
|
import NotFound from "./pages/NotFound";
|
||||||
import ResetPassword from "./pages/ResetPassword";
|
import ResetPassword from "./pages/ResetPassword";
|
||||||
@@ -24,9 +24,13 @@ import { PaymentTestModeBanner } from "@/components/PaymentTestModeBanner";
|
|||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
|
// Hash-baserad routing för miljöer utan SPA-rewrites (t.ex. förhandsvisning
|
||||||
|
// på en statisk sida). Standard är vanlig historik-routing.
|
||||||
|
const Router = import.meta.env.VITE_HASH_ROUTER ? HashRouter : BrowserRouter;
|
||||||
|
|
||||||
function AppContent() {
|
function AppContent() {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<Router>
|
||||||
<PaymentTestModeBanner />
|
<PaymentTestModeBanner />
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Index />} />
|
<Route path="/" element={<Index />} />
|
||||||
@@ -48,7 +52,7 @@ function AppContent() {
|
|||||||
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</Router>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user