Using basePath breaks SPA when using getServerSideProps or getStaticProps
See original GitHub issueBug report
Describe the bug
Setting basePath breaks SPA fetches and causes full re-render.
To Reproduce
- Set basePath to project in next.config.js
- Add either
getServerSideProps
orgetStaticProps
andgetStaticPaths
method to a page.
Repo for testing: https://github.com/IikkaWinter/next-basepath-demo
Deployments with basePath: https://nextjs-blog-d3av2acke.vercel.app/docs/foo
without basePath (everything works): https://nextjs-blog-2o56gnpjr.vercel.app/foo
Everything works as expected when run locally with vc dev
. Deploy to Vercel and every _next/data//.json path returns 404.
Expected behavior
Expected to run serverside method and return 200.
Screenshots
OBS! Prerendered page1.json and page2.json work.
foo.json
missing. Also see how Lambda function is named instead of /foo
.
System information
- OS: macOS
- Browser (if applies) Chrome
- Version of Next.js: 9.5.5
- Version of Node.js: 12.13.0
Additional context
Additionally, when using basePath (/docs) with rewrites and parameters in sources, e.g. /:locale/:path
, the route/docs/en
will pass the following parameters to the getServerSideProps:
{
locale: 'doc',
path: 'en'
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
Hi, this should be corrected now, please re-deploy your applications and give it a try!
Confirmed fixed!