I'm using Next.js as a replacement for Create React App. I'm not doing any server-side rendering or running any server-side code at all. The only thing the server needs to do is serve files to the browser. The workflow I'm used to from CRA is:
- Run
npm run build
on my computer - rsync the generated files to my shared hosting server
This worked great with my Next.js app, at first. But then I added routing - the new App Router with Next.js v13. It works fine in my dev environment. But on my shared host I'm getting 404 errors on all my routes, other than root. I'm guessing I need to add a .htaccess file, but I can't figure out what needs to be in it.
I noticed the generated files look like:
404.html
index.html
index.txt
myroute.html
myroute.txt
_next/
I need browser calls to both /myroute
and /myroute/12345
to work, and they do in dev, but the prod server doesn't seem to know what to do with them.