← 문제 목록
중급
Next.js
50P
redirect를 클라이언트에서 호출
다음 코드에서 버그를 찾으세요:
JAVASCRIPT
// app/components/LogoutButton.js
'use client';
import { redirect } from 'next/navigation';
export default function LogoutButton() {
async function handleLogout() {
await fetch('/api/auth/logout', { method: 'POST' });
redirect('/login');
}
return (
<button onClick={handleLogout}>
로그아웃
</button>
);
}
1명 풀이 · 정답률 100%