async function login() {
    const username = document.getElementById("username").value;
    const password = document.getElementById("password").value;
  
    const res = await fetch("http://127.0.0.1:4567/api/login", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      credentials: "include",  // ✅ セッションを有効にする
      body: JSON.stringify({ username, password })
    });
  
    const data = await res.json();
  
    if (res.ok) {
      document.getElementById("message").textContent = "ログイン成功";
      // ✅ ログイン後に地図画面へ移動
      window.location.href = "/";
    } else {
      document.getElementById("message").textContent = data.error || "ログイン失敗";
    }
  }
  