Recently, I purchased a Next.js template from Themeforest and attempted to deploy it to Zeit Now.
This particular project is set up as a monorepo using Lerna and Yarn workspace. The code for the Next.js app can be found inside the packages/landing
folder.
Initially, everything seemed to be working well with the index page (located at the /
route) as I could successfully reload it without any issues.
The problem arose when I tried adding new pages within the pages
folder, such as /privacy-policy
or /terms-of-service
.
If I navigated to these pages through a <Link />
from the index page, they worked perfectly fine. However, if I attempted to directly reload these pages or share their links with users, they would encounter a 404 NOT FOUND error instead.
You can observe this issue by visiting this page , where reloading works smoothly.
Contrastingly, upon opening this page , a 404 error is displayed even though the code for /saas
has been deployed.
In my local development environment, all pages function properly when reloaded. Thus, I suspect that the issue lies in the configuration of Zeit Now.
Here's the content of the now.json
file:
{
"version": 2,
"builds": [
{ "src": "packages/landing/package.json", "use": "@now/static-build" }
],
"routes": [
{
"src": "/(.*)",
"dest": "/packages/landing/$1",
"headers": {
"x-request-path": "$1"
}
}
]
}
How can I resolve this issue? Thank you.