diff --git a/src/components/app/routes/createAppRouter.test.jsx b/src/components/app/routes/createAppRouter.test.jsx index baee53fba..80f810af4 100644 --- a/src/components/app/routes/createAppRouter.test.jsx +++ b/src/components/app/routes/createAppRouter.test.jsx @@ -134,6 +134,14 @@ describe('createAppRouter', () => { usesQueryClient: false, }], }, + { + currentRoutePath: '/test-enterprise/invite/enterprise-customer-invite-key', + expectedRouteTestId: 'invite', + expectedRouteLoaders: [{ + loader: makeEnterpriseInviteLoader, + usesQueryClient: false, + }], + }, { currentRoutePath: '/test-enterprise', expectedRouteTestId: 'dashboard', diff --git a/src/routes.tsx b/src/routes.tsx index ae89823b9..f9314201f 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -214,6 +214,28 @@ function getOtherRoutes() { }; }, }, + { + /** + * We want to support a slug-"aware" version of the invite key route, + * but we don't want it nested under the root loader via + * enterpriseSlugRoutes above. Putting this route under the root loader + * would mean that the post-registration redirect back to this route + * would run through the root loader logic with a now-authenticated-but-unlinked + * requesting user, which will throw a 404 (until the async call to + * `link-user/` resolves and the page is reloaded). + */ + path: ':enterpriseSlug/invite/:enterpriseCustomerInviteKey', + lazy: async () => { + const { + default: EnterpriseInviteRoute, + makeEnterpriseInviteLoader, + } = await import('./components/app/routes/EnterpriseInviteRoute'); + return { + Component: EnterpriseInviteRoute, + loader: makeEnterpriseInviteLoader(), + }; + }, + }, ]; return otherRoutes; }