Some of public folder assets is not accessable when deploying NextJS app with basePath

Hello, I have a NextJS built with TypeScript and deployed on Netlify with @netlify/plugin-nextjs

- preview deploy

I’m using /m basePath on this web application, and everything works great, except some files under the public folder are not accessible like manifest or favicon files.

Also its important to say I made this app PWA with next-pwa

To make this base path work well on deployment This is my netlify.toml:

[build]
command = "npm run build"
publish = ".next"

[[plugins]]
package = "@netlify/plugin-nextjs"

[[redirects]]
from = "/"
to = "/m"
status = 301
force = true

Of course, locally everything works great.

For example, I will show the problem with the manifest file:


But, the manifest/favicon is accessible on the root route (‘/’)…

I need them to be accessible on /m like the rest of my public assets.
Things I tried:

  • netlify.toml assets redirect:
[[redirects]]
from = "/_next/static/*"
to = "/static/:splat"
status = 301
force = true
  • When I’m accessing those files, add /public OR /m OR just plain file (the correct way)
      <link
        rel="manifest"
        href="manifest.json" | href="/m/manifest.json" | href="public/manifest.json" 
      />
  • doing the redirect with middleware file

Thanks to everyone that will help!

Hey @Flaysh,

While the Netlify Redirect way to fix this would be:

[[redirects]]
from = "/*"
to = "/m"
status = 301
force = true

I’d rather think, you should use:

Are you already doing that?