Exporting router destinations AND a fallback

I want to set up a split test for my Layer0 environment using Router destinations. However I want to make sure traffic continues to hit a fallback route in the time period between deploying the router update and defining the split test rule utilizing the new destinations. I tried doing:

  const appRouter = new Router();
  appRouter.destination(
    'nuxtApp', 
    new Router()
      .get('/cutover', ({ renderWithApp }) => {
        renderWithApp();
      })
      .fallback(({ proxy, cache }) => {
        cache({
          edge: false,
        });
        proxy('legacy');
      })
  );
  appRouter.destination(
    'legacyProxy', 
    new Router()
      .fallback(({ proxy, cache }) => {
        cache({
          edge: false,
        });
        proxy('legacy');
      })
  );
  appRouter.fallback(({ proxy, cache }) => {
    cache({
      edge: false,
    });
    proxy('legacy');
  });
  return appRouter;

My expectation is that when this is deployed, all traffic will be proxied to legacy since the destinations are not defined as part of a split test. However, the /nuxtPath route in my first destination is being matched when this is deployed.

Is the expected behavior here for all routes to be matched when a destination is not specified?

It appears that the first router attached to the root is the one used in the matching algorithm unless there’s another source of information that can hint at which router to use (see Router#run). This is likely a bug.

Thanks @RA80533 - got some further clarification as well:

  • If you have 2 destinations and no split test the first destinations router is used
  • Once you use .destination in a router everything else is ignored, so that fallback after the 2 destinations will never match

So the solution is to just define the first destination in the router as whatever the default should be. Docs will be updated to reflect this.