회원 불러오기 작업하는 중1

This commit is contained in:
2025-11-26 21:40:56 +09:00
parent 47eedf6837
commit 53a5713ddd
12 changed files with 494 additions and 809 deletions

View File

@@ -30,7 +30,15 @@ export default function AccountPage() {
async function fetchUserInfo() {
try {
const token = localStorage.getItem('token');
// localStorage와 쿠키 모두에서 토큰 확인
const localStorageToken = localStorage.getItem('token');
const cookieToken = document.cookie
.split('; ')
.find(row => row.startsWith('token='))
?.split('=')[1];
const token = localStorageToken || cookieToken;
if (!token) {
if (isMounted) {
router.push('/login');
@@ -38,7 +46,16 @@ export default function AccountPage() {
return;
}
const response = await fetch('https://hrdi.coconutmeet.net/auth/me', {
// localStorage에 토큰이 없고 쿠키에만 있으면 localStorage에도 저장 (동기화)
if (!localStorageToken && cookieToken) {
localStorage.setItem('token', cookieToken);
}
const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL
? `${process.env.NEXT_PUBLIC_API_BASE_URL}/auth/me`
: 'https://hrdi.coconutmeet.net/auth/me';
const response = await fetch(apiUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -154,6 +171,7 @@ export default function AccountPage() {
devVerificationState={
verificationState === 'changed' ? 'verified' : verificationState
}
initialEmail={userInfo.email}
/>
<MenuAccountOption