getServerSideProps data urls don't respect assetPrefix
See original GitHub issueBug report
Describe the bug
I have assetPrefix set because we are hosting multiple applications on the same domain and use a proxy to route paths.
assetPrefix = "reports"
The static asset urls are correct. Such as /reports/_next/static/development/pages/_app.js?ts=1587171521639.
However, the data fetching URLs are NOT including the prefix: /_next/data/development/reports/appointments/2020-03-18/2020-04-17.json.
To Reproduce
- Set assetPrefix to anything
- Create a page with
getServerSideProps - use the router (or Link) to go to that page on the client
- Observe in the network request inspector that the data urls do not include the assetPrefix.
Expected behavior
I would expect the assetPrefix to apply to ALL asset urls that start with _next/
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:13 (4 by maintainers)
Top Results From Across the Web
getServerSideProps data urls don't respect assetPrefix #11992
I have assetPrefix set because we are hosting multiple applications on the same domain and use a proxy to route paths. assetPrefix =...
Read more >Data Fetching: getServerSideProps - Next.js
getServerSideProps returns JSON which will be used to render the page. All this work will be handled automatically by Next.js, so you don't...
Read more >Next.js: The Good, Bad and Ugly - An Idiosyncratic Blog
If you've never heard about Next.js, it's a framework built on top ... The _next/data path does not respect assetPrefix or basePath value....
Read more >Next.js - Full Context Review
it will die on the internal. _next/data. requests for the json page data because that folder doesn't respect the. assetPrefix. nor the.
Read more >@sentry-internal/typescript | Yarn - Package Manager
Links. Official SDK Docs · TypeDoc ... "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott ......
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 Free
Top 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

@Timer In our case, this is not possible. The basePath is expecting a subfolder, and we want to use a subdomain. We are using
https://cdn.domain.comand for the proposed solution we have to usehttps://domain.com/cdn.Can this issue be reopened or do you want me to create a new one?
Poking about with the code (i’m no expert in the codebase), here seems to be the culprit:
https://github.com/zeit/next.js/blob/canary/packages/next/next-server/lib/router/router.ts#L94
Which seems to add an experimental
basePathif exists, rather than theassetPrefixas I would have expected (as gets added to the preload tags for the json files)A quick addition of the assetPrefix to this line fixes my problem (with an ssg site using
getStaticProps), but i’m questioning whether we’re misunderstanding the expected behaviour (with thebasePathaddition)?