Next.js Quiz App Deployment Issue - 404 NOT_FOUND
I’m experiencing a 404 error when trying to access my deployed Next.js quiz application at:
The error code is NOT_FOUND with ID: lhr1::hh7lj-1744278809623-d5fbec10eb90.
Project Details
-
Framework: Next.js 14.1.0
-
Build Command:
pnpm run build
-
Output Directory:
.next
-
Node.js Version: 18.x
Project Structure
├── app/
│ ├── layout.tsx
│ ├── page.tsx
│ └── globals.css
├── components/
│ ├── quiz-app.tsx
│ ├── quiz-question.tsx
│ ├── user-statistics.tsx
│ └── lazy-components.tsx
├── lib/
│ └── db.ts
├── types/
│ └── question-types.ts
└── data/
└── question-bank.ts
Configuration Files
next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: {
ignoreDuringBuilds: false,
},
typescript: {
ignoreBuildErrors: false,
},
images: {
unoptimized: true,
domains: ['game.stutern.africa'],
},
experimental: {
webpackBuildWorker: true,
parallelServerBuildTraces: true,
parallelServerCompiles: true,
},
output: 'standalone',
poweredByHeader: false,
reactStrictMode: true,
swcMinify: true,
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Forwarded-Proto',
value: 'https',
},
{
key: 'X-Frame-Options',
value: 'DENY',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
],
},
];
},
async rewrites() {
return [
{
source: '/',
destination: '/',
},
{
source: '/:path*',
destination: '/:path*',
},
];
},
};
vercel.json
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/"
}
]
}
Environment Variables
NEXT_PUBLIC_BASE_URL=https://game.stutern.africa
POSTGRES_URL
(configured with PostgreSQL connection string)
Build Output
The build completes successfully with the following routes:
/
(24.5 kB)/_not-found
(888 B)/api/leaderboard
(0 B)/api/test-base-url
(0 B)
Issue
Despite successful builds and proper configuration, accessing the deployed application results in a 404 error. The application works correctly in development mode.
Troubleshooting Steps Taken
- Verified build output and routes
- Checked Next.js configuration
- Added Vercel-specific rewrite rules
- Confirmed environment variables are properly set
- Verified the root page component exists and exports correctly
Additional Context
- The application is a quiz app with multiple-choice questions
- Uses PostgreSQL for data storage
- Implements lazy loading for components
- Has proper TypeScript configurations
- Uses Tailwind CSS for styling
Any assistance in resolving this deployment issue would be greatly appreciated. Thank you!