Log user out then redirect

I’m using this code to log the user out and then redirect but it seems to be doing either redirecting user or logging out to (403)

export function logoutButton_onClick() {
 // user is logged in
  if(wixUsers.currentUser.loggedIn) {
    // log the user out
    wixUsers.logout()
      .then( () => {
        // redirect to homepage
wixLocation.to("https://www.wix.com");
    } );
  }
}

Hi,
The code looks fine, notice that if you are trying to redirect to the homepage as you described you need to redirect to “/home”.

Hope this helps :slight_smile: