'Using next.js with zones (one home app, one admin app). Receiving "destination` does not start with `/`" when attempting to start the app

I'm writing a Next.js app that has 2 apps that I essentially want to run as one app using next.js zones. I've been following along with the example here: https://github.com/vercel/next.js/tree/canary/examples/with-zones. The structure of my app has 2 separate folders, admin and home, each with their own next.config.js file:

Admin next.config.js:

module.exports = {
  basePath: '/admin',
}

Home next.config.js:

const CopyPlugin = require('copy-webpack-plugin');

const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
});

const { ADMIN_URL } = process.env

module.exports = withBundleAnalyzer({
  async rewrites() {
    return [
      {
        source: '/:path*',
        destination: `/:path*`,
      },
      {
        source: '/admin',
        destination: `${ADMIN_URL}/admin`,
      },
      {
        source: '/admin/:path*',
        destination: `${ADMIN_URL}/admin/:path*`,
      },
    ]
  },
  reactStrictMode: true,
  pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
  images: {
    domains: ['github.blog'],
    deviceSizes: [320, 640, 1080, 1200],
    imageSizes: [64, 128],
  },
  swcMinify: true,
  compiler: {
    styledComponents: true,
  },
  webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    config.module.rules.push({
      test: /\.svg$/,
      issuer: {
        and: [/\.(js|ts)x?$/],
      },
      use: [{ loader: '@svgr/webpack' }, { loader: 'url-loader' }],
    });

    return config;
  },
});

When I run the app (starting using "yarn dev" in the home folder), I receive the following message:

destination does not start with /, http://, or https:// for route {"source":"/admin","destination":"undefined/admin"}

destination does not start with /, http://, or https:// for route {"source":"/admin/:path*","destination":"undefined/admin/:path*"}

I'm relatively new to next.js, so I'm sure I'm missing something simple in the rewrite rules. I really appreciate any assistance. Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source