I am developing two Next.js applications on my computer. The first application has the following redirect configuration in the next.config.js file:
/** @type {import('next').NextConfig} */
const nextConfig = {
async redirects() {
return [
{
source: '/',
destination: '/dashboard',
permanent: true,
},
];
},
};
export default nextConfig;
When I access the route “/”, the application correctly redirects to “/dashboard”.
The second application has no redirect configuration. Here is the next.config.mjs file of the second application:
import "./env.mjs"
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ["avatars.githubusercontent.com", "http://localhost:8000", "localhost"],
},
experimental: {
appDir: true,
esmExternals: 'loose',
},
};
export default nextConfig;
The problem is that, even after closing the first application and running the second one, the second application behaves as if it has the same redirect as the first application.
Note:
The issue occurs when using the same port (3000) for both applications.
Environment:
Next.js: v14
Node.js: v21.6.1
Operating System: macOS Big Sur
Question:
What could be causing this behavior, and how can I ensure that the second application does not inherit the redirect configuration from the first?
Closing the first application before starting the second one.
Checking the redirect configurations in the second application.
Nélio Bila is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.