fail fetching getServerSideProps with basePath
See original GitHub issueBug report
Describe the bug
next 9.5.0 issue
After I setuped next.config.js
like below,
assetPrefix: "/resources/20200728145115"
basePath: "/ssr"
when I tried to change path by router, fetching getServerSideProps was failed with 404 error.
So I checked data fetch url, it contains assetPrefix instead of basePath.
/resources/20200728145115/_next/data/LzktM7sKix9_y5d3dr7ph/[pageRoute]
System information
Version of Next.js: 9.5.0 Version of Node.js: 10.13.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Data Fetching: getServerSideProps - Next.js
If an error is thrown inside getServerSideProps , it will show the pages/500.js file. Check out the documentation for 500 page to learn...
Read more >Nextjs failing on getServerSideProps for no reason
When sending https requests, try adding async / await to handle Promises that axios or fetch or httpRequest returns. Here is an example....
Read more >NextJS / React SSR: 21 Universal Data Fetching Patterns ...
They have clearly stated that fetching data in "getServerSideProps" doesn't scale well with a large number of pages and components.
Read more >Next.js: The Good, Bad and Ugly - An Idiosyncratic Blog
Next.js exposes APIs that can be use to fetch data and pre-render a ... getServerSideProps is executed on each request sent to the...
Read more >Data fetching with Next.js and Strapi CMS - LogRocket Blog
//frontend/utils.js const baseUrl = process.env. ... to prerender the page on each request using the data returned by getServerSideProps .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using
assetPrefix
for serving js/css from a different host than the Next.js server is running on. SincegetServerSideProps
is executed for each request I wouldn’t expect this to be served from the same location as static files.For example:
The user visits https://myapp.example.com/basepath/page Which loads js like this as expected https://mycdn.example.com/app_path/_next/static/chunks/pages/(...).js And I would expect getServerSideProps requests to look like this: https://myapp.example.com/basepath/_next/data/(...).json But instead they end up looking like this: https://mycdn.example.com/app_path/_next/data/(...).json
Since mycdn.example.com is just serving a folder with staticfiles this can’t work.
In #11992 it looks like people are trying to use assetPrefix as basePath IMO which kinda makes sense as basePath support was just released.
This was just fixed in 9.5.1, please upgrade!