question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Public assets with subPath don't work in production build

See original GitHub issue

Bug report

Public assets with subPath don’t work in production build

To Reproduce

  1. npx create-next-app
  2. Add next.config.js with content
module.exports = {
  basePath: '/test/sub-path',
  trailingSlash: false,
}
  1. 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} />
  1. Run dev application npm run dev - everything works fine
  2. 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ricardoGlobantcommented, Oct 15, 2020

Is there any workaround for this issue while the fix is ready?

1reaction
marcin-piela-sfcommented, Sep 18, 2020

Yes, and it works on 9.5.2 correctly

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found