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]
Version of Next.js: 9.5.0
Version of Node.js: 10.13.0
This behavior was changed as a bug fix, requested in https://github.com/vercel/next.js/issues/11992. Could you please explain what your assetPrefix is being used for and your use case more?
I'm using assetPrefix for serving js/css from a different host than the Next.js server is running on.
Since getServerSideProps is executed for each request I wouldn't expect this to be served from the same location as static files.
For example:
basePath: "/basepath",
assetPrefix: "https://mycdn.example.com/app_path/"
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.
Same case as @duvholt.
I expected that getServerSideProps fetching url have to contain basePath, not assetPrefix.
assetPrefix is added for cdn static files like js/css.
Also have same use case as @duvholt . Is the json data something I should serve from CDN as a short-term stopgap?
This was just fixed in 9.5.1, please upgrade!
Thanks @Janpot and @Timer. We used the fix in 9.5.1-canary.2 early today and it worked as expected, will upgrade to 9.5.1 shortly
Most helpful comment
I'm using
assetPrefixfor serving js/css from a different host than the Next.js server is running on.Since
getServerSidePropsis 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.