'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; export default function AdminLoginPage() { const router = useRouter(); const [id, setId] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); setLoading(true); try { const res = await fetch('/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, password }), }); const data = await res.json(); if (!res.ok) { setError(data.error || '로그인에 실패했습니다.'); } else { router.push('/admin/dashboard'); } } catch { setError('서버 연결에 실패했습니다.'); } finally { setLoading(false); } } return (
쟁승메이드 관리자 전용
.env.local의 ADMIN_ID / ADMIN_PASSWORD로 로그인