Next.js 404 page after successful deployment

ehiaig
HOBBY

7 days ago

I had a successful deployment of my nextjs app but when I visit the site, I get the 404 page.
On my local, I'm able to access the app correctly after running npm run dev and even after I run npm run build + npm run start . These are the same commands I set in the projects settings page.

Here's the latest deployment log:
```
Starting Container

npm warn config production Use --omit=dev instead.

> clearsay@0.0.0 start

> next start

▲ Next.js 15.4.4

- Local: http://localhost:8080

✓ Starting...

✓ Ready in 750ms
```
My package.json scripts:
```
"scripts": {

"dev": "next dev",

"build": "next build",

"start": "next start",

"lint": "eslint ."

},
```
next.config.mjs:
```
/** @type {import('next').NextConfig} */

const nextConfig = {

reactStrictMode: true,

basePath: process.env.NEXT_PUBLIC_BASE_PATH,

}

export default nextConfig
```

$10 Bounty

5 Replies

Railway
BOT

7 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


wiqayaai
FREE

7 days ago

If you're not really using a custom base path, then remove basePath completely:

// next.config.mjs

const nextConfig = {

reactStrictMode: true,

// basePath: process.env.NEXT_PUBLIC_BASE_PATH, ← remove this line

}

Then r

edeploy.


wiqayaai

If you're not really using a custom base path, then remove basePath completely:// next.config.mjsconst nextConfig = {reactStrictMode: true,// basePath: process.env.NEXT_PUBLIC_BASE_PATH, ← remove this line}Then redeploy.

wiqayaai
FREE

7 days ago

const nextConfig = {

reactStrictMode: true,

// Remove this line completely (bottom)

// basePath: process.env.NEXT_PUBLIC_BASE_PATH

}


ehiaig
HOBBY

6 days ago

Thanks @wiqayai, I did that but it had no effect


ehiaig
HOBBY

6 days ago

I resolved this by moving my pages/ folder to the root folder instead of inside src/pages where it was