Skip to content

Commit d386c1e

Browse files
author
Flatlogic Bot
committed
fix: add explicit 403/500 routes and improve error page handling
1 parent c21c717 commit d386c1e

3 files changed

Lines changed: 38 additions & 6 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ Looking for a perfect codebase generator for your Startup? Try [Flatlogic AI Web
6060

6161
---
6262

63+
## 📌 Current Stack Snapshot
64+
65+
- React `19.2.4`
66+
- MUI `7.x` + Emotion
67+
- React Router `5.x` (Browser History, no hash routing)
68+
- Redux + Context (transitional architecture before consolidation)
69+
- CRA (`react-scripts`) + `react-app-rewired` (Vite migration is planned)
70+
- Frontend-only users/auth fallback is available when backend is disabled
71+
72+
---
73+
6374
## 🧩 Features
6475

6576
- Three Color Themes

src/components/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ export default function App() {
3838
render={() => <Redirect to='/app/dashboard' />}
3939
/>
4040

41+
<Route exact path='/403' render={() => <Error code={403} />} />
42+
<Route exact path='/500' render={() => <Error code={500} />} />
4143
<Route path='/documentation' component={Documentation} />
4244
<PrivateRoute path='/app' component={Layout} />
4345
<PublicRoute path='/login' component={Login} />
4446
<PublicRoute path='/verify-email' exact component={Verify} />
4547
<PublicRoute path='/password-reset' exact component={Reset} />
46-
<Redirect from='*' to='/app/dashboard' />
4748
<Route component={Error} />
4849
</Switch>
4950
</Router>

src/pages/error/Error.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Grid, Paper } from '@mui/material';
3-
import { Link } from 'react-router-dom';
3+
import { Link, useLocation } from 'react-router-dom';
44
import classnames from 'classnames';
55

66
// styles
@@ -12,8 +12,28 @@ import { Button, Typography } from '../../components/Wrappers';
1212
// logo
1313
import logo from './logo.svg';
1414

15-
export default function Error() {
15+
const ERROR_CONTENT = {
16+
403: {
17+
title: 'Access denied',
18+
description: "You don't have permissions to view this page",
19+
},
20+
404: {
21+
title: "Page doesn't exist",
22+
description: "Looks like the page you're looking for no longer exists",
23+
},
24+
500: {
25+
title: 'Server error',
26+
description: 'Something went wrong while processing your request',
27+
},
28+
};
29+
30+
export default function Error({ code }) {
1631
let classes = useStyles();
32+
const location = useLocation();
33+
const queryParams = new URLSearchParams(location.search);
34+
const queryCode = Number(queryParams.get('code'));
35+
const errorCode = Number(code) || queryCode || 404;
36+
const content = ERROR_CONTENT[errorCode] || ERROR_CONTENT[404];
1737

1838
return (
1939
<Grid container className={classes.container}>
@@ -29,18 +49,18 @@ export default function Error() {
2949
color='primary'
3050
className={classnames(classes.textRow, classes.errorCode)}
3151
>
32-
404
52+
{errorCode}
3353
</Typography>
3454
<Typography variant='h5' color='primary' className={classes.textRow}>
35-
Oops. Looks like the page you're looking for no longer exists
55+
{content.title}
3656
</Typography>
3757
<Typography
3858
variant='h6'
3959
color='text'
4060
colorBrightness='hint'
4161
className={classnames(classes.textRow, classes.safetyText)}
4262
>
43-
But we're here to bring you back to safety
63+
{content.description}
4464
</Typography>
4565
<Button
4666
variant='contained'

0 commit comments

Comments
 (0)