document.getElementById("login-form").addEventListener("submit", async (event) => { event.preventDefault(); // Prevent the form from submitting the traditional way const codeword = document.getElementById("codeword").value; // Sending POST request to the backend const response = await fetch("/auth/login", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ codeword: codeword }), }); if (response.ok) { // Redirect to index.html after successful login window.location.href = "/index"; // Здесь может быть путь, где находится ваш index.html } else { alert("Указан неверный идентификатор входа"); } });