Public assets with subPath don't work in production build
npx create-next-appnext.config.js with contentmodule.exports = {
basePath: '/test/sub-path',
trailingSlash: false,
}
pages/index.js and replace line<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
with
<img src="/test/sub-path/vercel.svg" alt="Vercel Logo" className={styles.logo} />
npm run dev - everything works finenpm run build npm run start - static image asset doesn't work - 404Public assets should work in dev and prod
I am experiencing the exact same issue today on an identical system.
Interestingly, building a static site with next export does work, which leads me to believe it's the next server module itself where the bug lies.
Yes, and it works on 9.5.2 correctly
Any progress on it?
This is also preventing us from upgrading past 9.5.2. I see that a PR was already opened, but I may take a crack at it if it will get us moving forward on this fix.
Is there any workaround for this issue while the fix is ready?
@ricardoGlobant I have worked around this by using the custom server setup of Next JS and using express static to serve those files. This is _ok_ but obviously comes with all the downsides of using a custom server.
https://nextjs.org/docs/advanced-features/custom-server
https://expressjs.com/en/starter/static-files.html