Next.js app routing not working after deployment to cPanel

2.7k views Asked by At

I just deployed my next app on cPanel using buddy works and Github. The overall process was fluent and working properly and i was able to upload my .next folder to public.html folder of cPanel. But after uploading the files and visiting the domain i found that the only page that was correctly rendered was the first page with the route ('/'). On clicking on other routes i was met with the following error page

Error displayed on all other routes

Only after adding .html extension to the end of the route i was able to get the desired page. Attaching the screenshot for that here

enter image description here

I have gone through all the next js documentation available and i still am not able to sort this issue out properly. If anyone can point to what i am doing wrong here would be great help. Thanks!

1

There are 1 answers

1
Shubham Waje On

You have to add trailingSlash key in next.config.js as follows:

module.exports = {
  trailingSlash: true,
  ...
}

and then build your project in the same way you are building now.