Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Default RPC endpoints:

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

Expand Down
38 changes: 3 additions & 35 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { useCallback, useEffect } from "react";
import {
HashRouter,
Navigate,
Route,
BrowserRouter as Router,
Routes,
useLocation,
useNavigate,
} from "react-router-dom";
import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom";
import { cssVariables, getRainbowKitTheme } from "./theme";
import { getBaseDomainUrl, getSubdomain, getSubdomainRedirect } from "./utils/subdomainUtils";

// Detect if we're running on GitHub Pages and get the correct basename
function getBasename(): string {
const { hostname, pathname } = window.location;

// Check if we're on GitHub Pages
if (hostname.includes("github.io")) {
// Extract repo name from pathname (first segment after domain)
const pathSegments = pathname.split("/").filter(Boolean);
if (pathSegments.length > 0) {
return `/${pathSegments[0]}`;
}
}

// For local development or custom domains, no basename needed
return "";
}

import ErrorBoundary from "./components/common/ErrorBoundary";
import Footer from "./components/common/Footer";
import { IsometricBlocks } from "./components/common/IsometricBlocks";
Expand Down Expand Up @@ -64,9 +39,6 @@ import {
import { SettingsProvider, useSettings, useTheme } from "./context/SettingsContext";
import { useAppReady, useOnAppReady } from "./hooks/useAppReady";

// Detect GH Pages once
const isGhPages = typeof window !== "undefined" && window.location.hostname.includes("github.io");

// Component that handles subdomain redirects
function SubdomainRedirect() {
const navigate = useNavigate();
Expand Down Expand Up @@ -159,17 +131,13 @@ function AppContent() {

// Main App component that provides the theme context
function App() {
const BaseRouter = isGhPages ? HashRouter : Router;
// IMPORTANT: no basename for HashRouter
const basename = isGhPages ? "" : getBasename();

return (
<ErrorBoundary>
<SettingsProvider>
<RainbowKitProviderWrapper>
<BaseRouter basename={basename}>
<HashRouter>
<AppContent />
</BaseRouter>
</HashRouter>
</RainbowKitProviderWrapper>
</SettingsProvider>
</ErrorBoundary>
Expand Down
5 changes: 5 additions & 0 deletions src/utils/subdomainUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export function getSubdomain(): string | null {
return null;
}

// Skip subdomain processing for ENS gateways (e.g., openscan.eth.link, openscan.eth.limo)
if (hostname.endsWith(".eth.link") || hostname.endsWith(".eth.limo")) {
return null;
}

// Handle localhost subdomains (e.g., ethereum.localhost)
if (hostname.endsWith(".localhost")) {
return hostname.replace(".localhost", "");
Expand Down
Loading