document.addEventListener('DOMContentLoaded', e => { // check if the user is logged in, if not redirect to login fetch('/api/user/isLoggedIn').then(res => { if (!res.ok) { window.location.href = './'; } }); })