Next.js 14.2, and output: "export" combined with basePath

module.exports = {
  output: "export",
  basePath: "/test",
}

Using the above next.js config and npm run build to do a static deploy to the out folder. I’m testing with http-server out. Trying to reach localhost:8080:/test/characters but get a 404. However, localhost:8080/characters works, which seems wrong. I’d expect the page to be reached using localhost:8080:/test/characters.

If I try npm run dev everything works fine, I can reach my page via localhost:3000/test/characters.

Therefore, is output: "export" incompatible with “basePath”? If I remove output: "export" and do an npm run build && npm run start, it also appears to work as expected. Requires a nextjs server however and I want to ultimately use nginx to host a static site.

FYI using Next.js 14.2 and the app router.

Thanks!

Kam.

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.

It looks like related to Static export with a specified basePath causes request mismatch for RSC payload .txt file · Issue #73427 · vercel/next.js · GitHub

Doesn’t look like it’s been merged into canary yet so I can’t test it out. Even if it is merged will it be back ported to fix Next.js 14?

I guess I’m asking if I should plan on finding another solution like dropping output: 'export' if this won’t be resolved anytime soon.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.