Public assets with subPath don't work in production build
See original GitHub issueBug report
Public assets with subPath don’t work in production build
To Reproduce
npx create-next-app
- Add
next.config.js
with content
module.exports = {
basePath: '/test/sub-path',
trailingSlash: false,
}
- Edit file
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} />
- Run dev application
npm run dev
- everything works fine - Run prod application
npm run build
npm run start
- static image asset doesn’t work - 404
Expected behavior
Public assets should work in dev and prod
System information
- OS: macOs
- Version of Next.js: 9.5.3
- Version of Node.js: v13.14.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
create-react-app build doen't work in sub directory path
I've used express node web server. 'create-react-app build' is working on root directory.But, It doesn't work on subdirectory. For example,. localhost ...
Read more >Building for Production - Vite
Public Base Path If you are deploying your project under a nested public path, simply specify the base config option and all asset...
Read more >API - ESBuild
Tsconfig; Working directory. #Simple options. #Alias. Supported by: Build. This feature lets you substitute one package for another when bundling ...
Read more >Build configuration overview - Netlify Docs
From Build settings, you can set a base directory, add a build command, and specify a publish directory. For public repos, you can...
Read more >Public Path - webpack
The publicPath configuration option can be quite useful in a variety of scenarios. It allows you to specify the base path for all...
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
Is there any workaround for this issue while the fix is ready?
Yes, and it works on 9.5.2 correctly