_redirects + Nextjs dynamic routes - router.query is empty

The company I work for is looking to move our sites to Netlify. I was tasked with figuring out redirects.

I’ve created 2 github repos with a very basic NextJS site on each.

I then created 2 Netlify sites.

Main site: https://avetti.netlify.app/
Sub site: https://avetti-subsite.netlify.app/

_redirects under main site:

/shop https://avetti-subsite.netlify.app 200
/shop/* https://avetti-subsite.netlify.app/:splat 200

All seems to be working fine apart from the dynamic routes I created on the subsite.

here’s the code for my dynamic route:

import { useRouter } from "next/router";

const SubDynamic = () => {
  const router = useRouter();
  const slug = (router.query.slug as string[]) || [];

  return (
    <>
      <h1>Slug: {slug.join("/")}</h1>
      <pre>
        <code>{JSON.stringify(router, null, 2)}</code>
      </pre>
    </>
  );
};

export default SubDynamic;

you can access it here: https://avetti-subsite.netlify.app/subroute/1/hello
everything works just fine accessing from the sub site domain

but if I use the main site: https://avetti.netlify.app/shop/subroute/1/hello
redirects to get to the same page, I’m missing the router.query data, the “asPath” shows subroute/[…slug] instead of subroute/1/hello

What could be the issue here? Any help is greatly appreciated.

Hey @lberteh,

Unfortunately, this is a platform-level limitation as of today. We have an issue open, but this will still take a long time before this is supported, if at all that is.