Recently I bought a Next.js template on Themeforest and I tried to deploy it to Zeit Now.
This is a monorepo that using Lerna and Yarn workspace. Code of the Next.js app is inside packages/landing folder
Everything is fine with the index page (the page at / route), I can reload it without any problem.
The problem arises when I tried to add a new page inside pages folder. For example /privacy-policy or /terms-of-service, ...
If I navigate the these pages through a <Link /> from the index page, it works fine. But if I tried to reload these pages or send my users a direct link to them, they can't access these pages. Instead, my users will see 404 NOT FOUND.
You can see what I mean by going to this page https://superprops-2-r09pdhfab.now.sh/. It works fine when reloading.
But if you open this page https://superprops-2-r09pdhfab.now.sh/saas, you will see 404 (the code for /saas is also deployed)
In my localhost development, it works fine for all pages when reloading. So I think that the problem is from Zeit Now configuration.
This is the code inside now.json:
{
"version": 2,
"builds": [
{ "src": "packages/landing/package.json", "use": "@now/static-build" }
],
"routes": [
{
"src": "/(.*)",
"dest": "/packages/landing/$1",
"headers": {
"x-request-path": "$1"
}
}
]
}
How to fix this? Thank you.