(function() { // Get the user from localStorage const user = localStorage.getItem('user'); // Check if the user object exists. If not, redirect to the login page. if (!user) { // Use window.location.replace() to prevent the user from clicking the "back" button // and re-accessing the protected page. window.location.replace('/frontend/index.html'); } })();