Skip to content

Commit 4de334d

Browse files
authored
Merge pull request #144 from AugustoL/fix/ipfs-ens-routing
fix: IPFS/ENS routing compatibility
2 parents 423878a + a7b8af2 commit 4de334d

3 files changed

Lines changed: 9 additions & 36 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Default RPC endpoints:
246246

247247
- **React 19** - UI framework
248248
- **TypeScript** - Type safety
249-
- **React Router** - Client-side routing
249+
- **React Router** - Client-side routing (HashRouter for IPFS/ENS compatibility)
250250
- **Custom RPC Service** - Direct JSON-RPC calls to blockchain nodes
251251
- **Biome** – Code formatting and linting
252252

src/App.tsx

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
11
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
22
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";
124
import { cssVariables, getRainbowKitTheme } from "./theme";
135
import { getBaseDomainUrl, getSubdomain, getSubdomainRedirect } from "./utils/subdomainUtils";
146

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-
327
import ErrorBoundary from "./components/common/ErrorBoundary";
338
import Footer from "./components/common/Footer";
349
import { IsometricBlocks } from "./components/common/IsometricBlocks";
@@ -64,9 +39,6 @@ import {
6439
import { SettingsProvider, useSettings, useTheme } from "./context/SettingsContext";
6540
import { useAppReady, useOnAppReady } from "./hooks/useAppReady";
6641

67-
// Detect GH Pages once
68-
const isGhPages = typeof window !== "undefined" && window.location.hostname.includes("github.io");
69-
7042
// Component that handles subdomain redirects
7143
function SubdomainRedirect() {
7244
const navigate = useNavigate();
@@ -159,17 +131,13 @@ function AppContent() {
159131

160132
// Main App component that provides the theme context
161133
function App() {
162-
const BaseRouter = isGhPages ? HashRouter : Router;
163-
// IMPORTANT: no basename for HashRouter
164-
const basename = isGhPages ? "" : getBasename();
165-
166134
return (
167135
<ErrorBoundary>
168136
<SettingsProvider>
169137
<RainbowKitProviderWrapper>
170-
<BaseRouter basename={basename}>
138+
<HashRouter>
171139
<AppContent />
172-
</BaseRouter>
140+
</HashRouter>
173141
</RainbowKitProviderWrapper>
174142
</SettingsProvider>
175143
</ErrorBoundary>

src/utils/subdomainUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export function getSubdomain(): string | null {
1818
return null;
1919
}
2020

21+
// Skip subdomain processing for ENS gateways (e.g., openscan.eth.link, openscan.eth.limo)
22+
if (hostname.endsWith(".eth.link") || hostname.endsWith(".eth.limo")) {
23+
return null;
24+
}
25+
2126
// Handle localhost subdomains (e.g., ethereum.localhost)
2227
if (hostname.endsWith(".localhost")) {
2328
return hostname.replace(".localhost", "");

0 commit comments

Comments
 (0)