-
Notifications
You must be signed in to change notification settings - Fork 0
Add custom 404 and error pages with consistent layout and Azure Static Web Apps configuration #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: lfarci <31938998+lfarci@users.noreply.github.com>
|
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
Co-authored-by: lfarci <31938998+lfarci@users.noreply.github.com>
src/src/app/error.tsx
Outdated
| import { useEffect } from "react"; | ||
| import { useRouter } from "next/navigation"; | ||
|
|
||
| export default function Error({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot avoid using such a generic name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the function from Error to GlobalError for better clarity and specificity. (c9561f6)
Co-authored-by: lfarci <31938998+lfarci@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. |
|
@copilot the error page is not reachable |
Co-authored-by: lfarci <31938998+lfarci@users.noreply.github.com>
Fixed! Added The custom 404 page will now be served on Azure instead of the default Azure 404 page. |
|
@copilot it looks like a fix but make sure to use typography components to have corrects fonts |
Co-authored-by: lfarci <31938998+lfarci@users.noreply.github.com>
Updated both error pages to use typography components ( |
|
@copilot not found page should reuse the error component, maybe rename error to ErrorMessage component |
|
@copilot try again |
|
@copilot try again |
Co-authored-by: lfarci <31938998+lfarci@users.noreply.github.com>
|
@copilot in the not found page the button should be another component |
|









Create Custom 404 and Error Pages ✅
not-found.tsxpage for 404 errors that uses the site's layouterror.tsxpage for general errors that uses the site's layoutScreenshots
404 Page (Light Mode)

404 Page (Dark Mode)

Error Page (Light Mode)

Error Page (Dark Mode)

Changes Made
src/src/app/not-found.tsx- Custom 404 error page with clean designsrc/src/app/error.tsx- Custom error boundary page with retry functionalitysrc/public/staticwebapp.config.json- Azure Static Web Apps configuration to route 404 errors to custom pagesrc/src/components/shared/ErrorMessage.tsx- Shared reusable component for consistent error page UIHeading1,Heading2,Text) for consistent font familiesuseRouterfor client-side navigation (no full page reload)ErrortoGlobalErrorfor better clarityKey Features
✅ Clean, user-friendly error messages
✅ Consistent branding and layout with the rest of the site
✅ Proper font families using typography components
✅ Shared ErrorMessage component for code reusability
✅ Functional "Back to Home" navigation using Next.js router
✅ Error page includes "Try Again" functionality
✅ Responsive design for mobile and desktop
✅ Dark mode support
✅ Production-ready error handling
✅ No security vulnerabilities
✅ Passes code review
✅ Clear and descriptive component names
✅ Azure Static Web Apps properly routes to custom 404 page
Technical Details
ErrorMessage Component:
ErrorMessage.tsxcomponent that encapsulates common error page UItitle,heading,messageprops for customizationnot-found.tsxanderror.tsxnow use this component, eliminating code duplicationTypography Components:
<h1>,<h2>, and<p>elements withHeading1,Heading2, andTextcomponentsheading-fontfor headings,text-fontfor body text)Azure Static Web Apps Configuration:
The
staticwebapp.config.jsonfile configures Azure to serve the custom 404 page instead of the default Azure 404:navigationFallbackhandles client-side routing fallback to/404.html(generated fromnot-found.tsx)responseOverridesensures proper 404 status codes are returnedSecurity Summary
No vulnerabilities were discovered. The implementation follows Next.js best practices for error handling and client-side navigation.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.