How can I redirect from one Next.js app with basePath set to another in an Nx monorepo setup?

82 Views Asked by At

I have an Nx monorepo setup with multiple Next.js apps. Each Next.js app has its basePath set to '/apps/appName' e.g. Users app's basePath is /apps/users. There's a root app that lists the applications and has no basePath set in order to run at / and one of its routes is /login. I am using redirect from next/navigation in the Users app to redirect to the root app's /login by writing redirect('/login'); but I redirect to /apps/users/login instead. The only way to achieve the desired result is by writing redirect('../../login');. Has anyone faced a similar problem before? I'm not liking the relative path passed in redirect.

0

There are 0 best solutions below