[feat]: 보호된 대시보드 및 API 라우트 추가

- 인증된 사용자용 대시보드 페이지 구현 ((protected) 라우트 그룹)
- API 엔드포인트 추가 (인증, 사용자 관리)
- 커스텀 훅 추가 (useAuth)
- 미들웨어 인증 로직 강화
- 환경변수 예제 업데이트
- 기존 dashboard 페이지 제거 후 보호된 라우트로 이동

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
byeongcheolryu
2025-11-10 09:38:59 +09:00
parent 56386e6d88
commit bf39fd22bd
14 changed files with 804 additions and 40 deletions

View File

@@ -0,0 +1,39 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
/**
* Auth Check Route Handler
*
* Purpose:
* - Check if user is authenticated (HttpOnly cookie validation)
* - Prevent browser back button cache issues
* - Real-time authentication validation
*/
export async function GET(request: NextRequest) {
try {
// Get token from HttpOnly cookie
const token = request.cookies.get('user_token')?.value;
if (!token) {
return NextResponse.json(
{ error: 'Not authenticated', authenticated: false },
{ status: 401 }
);
}
// Optional: Verify token with PHP backend
// (현재는 토큰 존재 여부만 확인, 필요시 PHP API 호출 추가 가능)
return NextResponse.json(
{ authenticated: true },
{ status: 200 }
);
} catch (error) {
console.error('Auth check error:', error);
return NextResponse.json(
{ error: 'Internal server error', authenticated: false },
{ status: 500 }
);
}
}