Next.js 14 Sub-Domain Redirect

175 Views Asked by At

I'm trying to add sub domain to my Next.js application to make dynamic domain pages. For example: sub.domain.com.

I have tried to use **Redirect **function in the next.config file like this, but it's a bit tricky:

const nextConfig = {
  async redirects() {
    return [
      {
        source: "/:path*",
        destination: "/",
        permanent: true,
      },
    ];
  },
};

module.exports = nextConfig;
0

There are 0 best solutions below