Need Relogin 3 times Only Able to Access Dynamic Page When Using Custom Sign Up Form

Hi, please help!! I still cant solve this problem.

I am using Custom Sign Up Form. When new members sign up, they can click on the “My Account button” (to access dynamic page) to check their profile.

But after successful signed up using custom form, I am not able to access the dynamic page. Error 404 will shown. I need to relogin 3 times only able to access the dynamic page.

If I select the Default Sign Up Form, there is no issue to click on “My Account button” after successful signed up.

https://testingmy.wixsite.com/mysite

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady( () => {
 if(wixUsers.currentUser.loggedIn) {
     $w("#myaccount").show();
     $w("#logout").show();
     $w("#loginsignup").hide();
 

  }
 else {
     $w("#myaccount").hide();
     $w("#logout").hide();
     $w("#loginsignup").show();
   }
 
} );

wixUsers.onLogin( (user) => {

  $w('#myaccount').show();
  $w('#logout').show();
  $w("#loginsignup").hide();
})

export function loginsignup_click() { 
 if(wixUsers.currentUser.loggedIn) {
    wixUsers.logout()
      .then( () => {
        $w("#myaccount").hide();
        $w("#logout").hide();
        $w("#loginsignup").show();
 
    } );
  }

 else {
 let userId;
 let userEmail;
 
 
    wixUsers.promptLogin( {"mode": "login"} )
      .then( (user) => {
        userId = user.id;
 return user.getEmail();
      } )
      .then( (email) => {
        userEmail = email;
 return wixData.query("myaccount")
          .eq("_id", userId)
          .find();
      } )
      .then( (results) => {
 if (results.items.length === 0) {
 const toInsert = {
 "_id": userId,
 "email": userEmail
          };

          wixData.insert("myaccount", toInsert)
            .catch( (err) => {
              console.log(err);
            } );
        }
 
        $w("#myaccount").show();
        $w("#logout").show();
        $w("#loginsignup").hide();
      } )
      .catch( (err) => {
        console.log(err);
      } );
  }
}

export function myaccount_click() {            
   wixLocation.to(`/myaccount/update/${wixUsers.currentUser.id}`);      
    }

$w.onReady(() => {
    $w("#logout").onClick(logoutAndRedirect); 
});

function logoutAndRedirect(event) {
    Promise.all( [ wixLocation.to('/'), wixUsers.logout() ] );
}

Any corvid master can assist please ?