Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NextJS assetPrefix and basePath prefix not taking effect

Tags:

next.js

I'm unsuccessfully attempting to create a simple NextJS site that has a /app prefix on all the links. So that on the home page (which has a link to /about), the About link should end up as /app/about.

(updated based on comments below) My next.config.js file looks like this:

module.exports = {
  assetPrefix: "/app",
  publicRuntimeConfig: {
    basePath: "/app",
  },
  basePath: "/app",
};

And my package.json's scripts section has:

    "build": "next build && next export",

However, when I copy the contents of the generated out folder into my web server, the index page's "About" link always points to /about without the desired prefix. What could be causing that? It appears as though the assetPrefix value is working:

enter image description here

So it's just the root basePath field that isn't working.

like image 852
Pat Needham Avatar asked Sep 07 '25 04:09

Pat Needham


1 Answers

This issue has been reported as fixed recently. https://github.com/vercel/next.js/pull/9872

Try to use the most recent canary release. At this moment it's 9.5.2-canary.18

like image 118
zoran jeremic Avatar answered Sep 10 '25 22:09

zoran jeremic