Next.js Discord

Discord Forum

Need help displaying routes/components in production

Unanswered
Error 404 posted this in #help-forum
Open in Discord
Avatar
Error 404OP
Hello i've been working on a little table application that displays scores.
My FrontEnd is Handled by Next and the BackEnd by Laravel.
By using the exact same repository and data when i run the command "npm run dev" it compiles and displays my table as depicted in the first image: and under the address "http://localhost:3001/weekly-scores"
following this tree structue:
┣ 📂(tableau)
┃ ┗ 📂weekly-scores
┃ ┗ 📜page.tsx
┣ 📂components
┃ ┣ 📂hooks
┃ ┃ ┗ 📜usePusher.tsx
┃ ┣ 📜TableComponent.module.css
┃ ┗ 📜TableComponent.tsx
┣ 📜favicon.ico
┣ 📜globals.css
┣ 📜layout.tsx
┗ 📜page.tsx
weekly score does display things but, once i build and try in production (i need to test a webhook) i just get a 404 error when accessing the route.
without any error in console to problem fix or figure what's going on aside the 404 error.
Another piece of useful information is that is my default page.tsx does compile and display as seen in image #3
it's just the address weekly-scores that's innaccesible in prod.
Thanks in advance for the help.
Image
Image
Image

20 Replies

Avatar
Southern rough shrimp
When you run npm run build, show the output of what pages are created, and their sizes
This
Image
Avatar
Error 404OP
Image
Avatar
Southern rough shrimp
I notice that on the working screenshot, you're on localhost, but the other screenshot you're on some .fr domain
Are you sure you pushed the proper changes?
Avatar
Error 404OP
i'm in the ssh host, i stopped the pm2 service, ran build, then started the service again
Image
at least for what i read i was suposed to stop the service, run build then start the service, and it displays well the baseline page.tsx
Avatar
Southern rough shrimp
Is there any way of seeing the output of the build on the remote?
i.e make sure it's not caching a build anywhere
Avatar
Error 404OP
mmm im not sure, since i'm not that well versed with pm2
gonna consult w my colleague that set it up as to recover the logs
Avatar
Error 404OP
well after investigating, the remote only does this as command:
tableau_nextjs_front@0.1.0 start
next start

â–² Next.js 14.1.0
- Local: http://localhost:3000

✓ Ready in 306ms
so i'd asume it launches the one done with the build command
it only starts and stops doesn't build, so i'd asume is the built instance that's rendered
Avatar
Southern rough shrimp
Yeah so you need to make sure the build is up to date
Avatar
Error 404OP
when i run
npm run build
it does that no? or am i missing a step to make sure?
Avatar
Southern rough shrimp
How does that build get to your remote cluster?
Avatar
Error 404OP
Through a ecosystem.config file.
module.exports = {
  apps : [{
    name   : 'f-prod',
    exec_mode: 'cluster',
    namespace: 'testing',
    instances: 'max',
    script : 'node_modules/next/dist/bin/next',
    args: 'start -p 3000'
  }]
}
Avatar
Error 404OP
Hello, sorry to comment again but i'd like to update.
instead of "stopping process" i had to delete them, and then the start command deployed properly the good build, it was indeed probably cached
Avatar
Southern rough shrimp
Could you mark the solution if it fixed it?