|
1 | 1 | import { RainbowKitProvider } from "@rainbow-me/rainbowkit"; |
2 | 2 | import { useCallback, useEffect } from "react"; |
3 | | -import { |
4 | | - HashRouter, |
5 | | - Navigate, |
6 | | - Route, |
7 | | - BrowserRouter as Router, |
8 | | - Routes, |
9 | | - useLocation, |
10 | | - useNavigate, |
11 | | -} from "react-router-dom"; |
| 3 | +import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom"; |
12 | 4 | import { cssVariables, getRainbowKitTheme } from "./theme"; |
13 | 5 | import { getBaseDomainUrl, getSubdomain, getSubdomainRedirect } from "./utils/subdomainUtils"; |
14 | 6 |
|
15 | | -// Detect if we're running on GitHub Pages and get the correct basename |
16 | | -function getBasename(): string { |
17 | | - const { hostname, pathname } = window.location; |
18 | | - |
19 | | - // Check if we're on GitHub Pages |
20 | | - if (hostname.includes("github.io")) { |
21 | | - // Extract repo name from pathname (first segment after domain) |
22 | | - const pathSegments = pathname.split("/").filter(Boolean); |
23 | | - if (pathSegments.length > 0) { |
24 | | - return `/${pathSegments[0]}`; |
25 | | - } |
26 | | - } |
27 | | - |
28 | | - // For local development or custom domains, no basename needed |
29 | | - return ""; |
30 | | -} |
31 | | - |
32 | 7 | import ErrorBoundary from "./components/common/ErrorBoundary"; |
33 | 8 | import Footer from "./components/common/Footer"; |
34 | 9 | import { IsometricBlocks } from "./components/common/IsometricBlocks"; |
@@ -64,9 +39,6 @@ import { |
64 | 39 | import { SettingsProvider, useSettings, useTheme } from "./context/SettingsContext"; |
65 | 40 | import { useAppReady, useOnAppReady } from "./hooks/useAppReady"; |
66 | 41 |
|
67 | | -// Detect GH Pages once |
68 | | -const isGhPages = typeof window !== "undefined" && window.location.hostname.includes("github.io"); |
69 | | - |
70 | 42 | // Component that handles subdomain redirects |
71 | 43 | function SubdomainRedirect() { |
72 | 44 | const navigate = useNavigate(); |
@@ -159,17 +131,13 @@ function AppContent() { |
159 | 131 |
|
160 | 132 | // Main App component that provides the theme context |
161 | 133 | function App() { |
162 | | - const BaseRouter = isGhPages ? HashRouter : Router; |
163 | | - // IMPORTANT: no basename for HashRouter |
164 | | - const basename = isGhPages ? "" : getBasename(); |
165 | | - |
166 | 134 | return ( |
167 | 135 | <ErrorBoundary> |
168 | 136 | <SettingsProvider> |
169 | 137 | <RainbowKitProviderWrapper> |
170 | | - <BaseRouter basename={basename}> |
| 138 | + <HashRouter> |
171 | 139 | <AppContent /> |
172 | | - </BaseRouter> |
| 140 | + </HashRouter> |
173 | 141 | </RainbowKitProviderWrapper> |
174 | 142 | </SettingsProvider> |
175 | 143 | </ErrorBoundary> |
|
0 commit comments