I simply followed the doc by adding this to my next.config.js
module.exports = {
 reactStrictMode: true,
 async redirects() {
 return [
 {
 source: "/",
 destination: "/coming-soon",
 permanent: false,
 },
 ];
 },
}
It does work on my machin even when I build the app but on netlify there is no redirect at all for some reason
- 
 You need custom configuration on your netlify instance: docs.netlify.com/routing/redirectsLinh– Linh2021年11月24日 16:58:44 +00:00Commented Nov 24, 2021 at 16:58
2 Answers 2
According to the official Netlify docs:
Redirects and rewrites using
next.config.jsaren't currently supported for Next.js sites on Netlify. If you have these specified in anext.config.jsfile for your project, check out our redirects and rewrites docs to learn how to set them up in a_redirectsornetlify.tomlfile instead.
So you basically need to create a _redirects file at the top level of your project with the following contents:
/ /coming-soon 302
The 302 status code is equivalent to permanent: false that you've done in your config.
If you have a netlify.toml, then you can add something like this to make your stuff work:
[[redirects]]
 from = "/"
 to = "/coming-soon"
 status = 302
 force = false
References:
1 Comment
When we deploy a Next.js project on Netlify it automatically gets all the necessary dependencies including the Essential Next.js plugin (If it is not installed in the plugin tab, we have to install it manually). This plugin configures your Netlify site to allow essential Next.js capabilities. Version 4 of the Essential Next.js plugin adds support for native Next.js rewrites and redirects.
Basically, you can use native Next.js redirects/rewrites (configured in next.config.js) in Netlify by installing the Essential Next.js plugin version 4 or higher to your Next.js site deployed in Netlify.
Refer this to learn more about using Next.js and Netlify redirects/rewrites rules.