#Middleware not check the path after /something/onboarding

4 messages · Page 1 of 1 (latest)

coarse aurora
#

I have this function which should redirect the user if there is auth token and onBoarding is true. P op

    // Check user onBoading status
    if (authToken && authToken?.onboardingDone == true) {
      console.log('admin onbaordin nehat run ')

      const requestedPath = request.nextUrl.pathname;

      const onBoardingRequestedPath = excludedUrlsOnbaording.some((url) =>{
        console.log(url)
        return requestedPath.startsWith(url)
      }
    );

    if (onBoardingRequestedPath) {
      // Redirect the user to a different URL
      return redirectToRoleHome(roles, request);
    }
    }

shadow spearBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

coarse aurora
#

  const excludedUrlsOnbaording = [
    "/entrepreneur/onboarding/",
    "/entrepreneur/common/",
    "/service-provider/onboarding/",
    "/service-provider/common/",
    "/expert/onboarding/",
    "/expert/common/",
    "/investor/onboarding/",
    "/investor/common/",
  ]

This is the array of urls which need to be checked but path after /something/onbaording/ is still accessible even after conditions is match

#

But when I try to/something/onbaording/ that it does redirect the user when the conditions is true