If you have assetPrefix: '/foo' in your config, this should cause all requests on the client for /_next/* to be made to /foo/_next/* instead.
The assetPrefix setting does not apply to certain /_next URLs, including chunks, HMR requests, and pings.
assetPrefiximport(...) How the assetPrefix: '/foo' setting affects various URLs:
/foo/_next/1502390442393/page/pay-gap/about/foo/_next/1502390442393/main.js/_next/webpack/chunks/---data-418bc291-7d03-4c09-a3b6-334ad7682fc1.js/_next/webpack-hmr/_next/on-demand-entries-ping?page=/some/page(I'm not sure if the above list is complete.)
Why this matters: I'm behind a routing layer that only sends me requests starting with /app-name. If a request does not start with /app-name, it will never reach my server. I need to be able to make all /_next requests go through /app-name/_next so that they reach my app. (Once they reach my app, the corresponding serverside workaround is easy: you can just strip off the prefix and then manually call Next's handler, as various people have suggested in #257.)
| Tech | Version |
|---------|---------|
| next | 3 |
| node | 8 |
| OS | macOS Sierra |
| browser | Chrome |
I found a workaround to get chunks working:
module.exports = {
assetPrefix: '/foo',
webpack: (config) => {
config.output.publicPath = `/foo${config.output.publicPath}`;
return config;
},
};
But I still think there should be a single place that you can prefix/customise the /_next and have it work for everything (hot module replacement, chunks, whatever).
Most helpful comment
I found a workaround to get chunks working:
But I still think there should be a single place that you can prefix/customise the
/_nextand have it work for everything (hot module replacement, chunks, whatever).