Skip to content
Open
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
64 changes: 61 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0"
"react-dom": "^19.2.0",
"react-router-dom": "^7.13.1"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
Expand Down
15 changes: 14 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import './App.css'
import { Route, Routes } from 'react-router-dom'
import NotFoundPage from './NotFoundPage'

function App() {
function HomeRoute() {

return (
<>
Expand All @@ -9,4 +11,15 @@ function App() {
)
}

function App() {
return (
<>
<Routes>
<Route path="/" element={<HomeRoute />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</>
)
}

export default App
12 changes: 12 additions & 0 deletions src/NotFoundPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Link } from 'react-router-dom'

export default function NotFoundPage() {
return (
<>
<h1>404</h1>
<p>Page not found.</p>
<Link to="/">Go home</Link>
</>
)
}

5 changes: 4 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import './index.css'
import App from './App.tsx'

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
<BrowserRouter>
<App />
</BrowserRouter>
Comment on lines +9 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Verify SPA fallback support for BrowserRouter.

This setup only handles misses after the client boots. A direct request or hard refresh on /xyz will still return a server 404 unless the deployed host rewrites unknown paths to index.html. Please confirm that rewrite exists, or use HashRouter if the target hosting cannot provide it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.tsx` around lines 9 - 11, The app currently uses BrowserRouter in
main.tsx (wrapping <App />) which requires the hosting to rewrite unknown paths
to index.html for direct navigations; verify the deployment configuration
provides that SPA fallback (rewrite/redirect unknown routes to index.html) and
confirm in the PR, or if the host cannot supply rewrites switch to HashRouter
(imported from react-router-dom and replace BrowserRouter with HashRouter around
<App />) so hard-refreshes/direct requests work without server rewrites.

</StrictMode>,
)
Loading