Next.js 404 page after successful deployment
ehiaig
HOBBYOP

10 months 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

10 months 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!


muhammed1447
FREE

10 months 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.


muhammed1447

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.

muhammed1447
FREE

10 months ago

const nextConfig = {

reactStrictMode: true,

// Remove this line completely (bottom)

// basePath: process.env.NEXT_PUBLIC_BASE_PATH

}


ehiaig
HOBBYOP

10 months ago

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


ehiaig
HOBBYOP

10 months ago

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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...