Pat Needham
Pat Needham

Reputation: 5638

NextJS assetPrefix and basePath prefix not taking effect

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.

Upvotes: 4

Views: 22972

Answers (1)

zoran jeremic
zoran jeremic

Reputation: 2138

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

Upvotes: 2

Related Questions