Netlify redirects from `next.config.js` don't work as the `@netlify/plugin-nextjs` is deactivated due to `next export`

Site: https://62ea4fd88956c0168947852a--lbstudio.netlify.app/
Stack: Nextjs (next export) + @netlify/plugin-nextjs - v4.12.2
Netlify config: NETLIFY_NEXT_PLUGIN_SKIP: false

Hi there!

I’m trying to use nextjs redirects in the next.config.js as they should be supported by now by the @netlify/plugin-nextjs plugin.

I have seen the order of redirects evaluation here and I’m sure the points 1-3 are not applied in my case, so the plugin should take the redirects from the config.

I’m using next export in the build process and I have the plugin active. The error message that I get is:

3:35:20 PM:   Error: The directory "/opt/build/repo/out" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
3:35:20 PM:   Your publish directory is set to "out", but in most cases it should be ".next".
3:35:20 PM:   If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true".

So far I was using the NETLIFY_NEXT_PLUGIN_SKIP set to true to fix that error, however I’d like to use the redirects from next.config.js which apparently can’t be done as the plugin is skipped due to next export.

Is there a way how to make these next.config.js redirects work with configuring the plugin to work with next export?

Thanks in advance!

No. I don’t think redirects specified in next.config.js are supposed to be used on a site using next export. next export is meant for static sites and to evaluate next.config.js and parse the redirects, you’d need Next.js server to be running.

You can use Netlify Redirects or Edge Functions to achieve what you might have configured in there.