Another way to handle it is to catch the onLogout event in the masterPage.js file. This would have the advantage that it would also redirect the users when they logout via the menu option. Adding this code to the masterPage.js will do the trick.
import wixLocation from ‘wix-location’;
import {authentication} from ‘wix-members’;
$w.onReady(function () {
// This event handler is fired when the member logs out of the app.
// Redirect the member back to the home page
authentication.onLogout(() => {
console.log(‘Member logged out.’);
wixLocation.to(“/”);
});
});