Skip to content

Commit 205cb9b

Browse files
committed
Fix: 리다이렉트 url에 환경 변수 추가
1 parent 031d87c commit 205cb9b

3 files changed

Lines changed: 10 additions & 28 deletions

File tree

src/pages/Login/components/Kakao/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const Kakao: React.FC = () => {
1010
const SERVER_URI = import.meta.env.VITE_NEW_API_URL;
1111

1212
const handleLogin = () => {
13-
// 리다이렉트 URL 설정 및 서버 URL 생성
14-
const redirectUrl = 'http://localhost:3000/login/complete';
13+
// 리다이렉트 URL 설정
14+
const redirectUrl = encodeURIComponent(`${import.meta.env.VITE_DOMAIN || window.location.origin}/login/complete`);
15+
16+
// 서버 URL 생성
1517
const serverUrl = `${SERVER_URI}/auth/login/kakao?redirectUrl=${redirectUrl}`;
1618

1719
// 서버로 리다이렉션
@@ -31,5 +33,4 @@ const Kakao: React.FC = () => {
3133
</SocialLogin>
3234
);
3335
};
34-
3536
export default Kakao;

src/pages/Login/components/Naver/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const Naver: React.FC = () => {
1010
const SERVER_URI = import.meta.env.VITE_NEW_API_URL;
1111

1212
const handleLogin = () => {
13-
// 리다이렉트 URL 설정 및 서버 URL 생성
14-
const redirectUrl = 'http://localhost:3000/login/complete';
13+
// 리다이렉트 URL 설정
14+
const redirectUrl = encodeURIComponent(`${import.meta.env.VITE_DOMAIN || window.location.origin}/login/complete`);
15+
16+
// 서버 URL 생성
1517
const serverUrl = `${SERVER_URI}/auth/login/naver?redirectUrl=${redirectUrl}`;
1618

1719
// 서버로 리다이렉션

src/pages/ProfileViewer/UserInfo/index.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,8 @@ const UserInfo: React.FC = React.memo(() => {
5757
setIsModalOpen(true);
5858
};
5959

60-
const checkPostCount = (): number => {
61-
// 자신의 게시물이 있는지 확인하는 함수
62-
const userDetails = localStorage.getItem(`userDetails_${my_id}`);
63-
if (userDetails) {
64-
const parsedDetails = JSON.parse(userDetails);
65-
return parsedDetails.postsCount || 0;
66-
}
67-
return 0;
68-
};
69-
7060
// 친구 요청 sendComment 함수
7161
const createMatching = async (message: string) => {
72-
const postsCount = checkPostCount();
73-
if (postsCount === 0) {
74-
setIsBottomSheetOpen(false);
75-
handleModalOpen('게시물 등록 후 \n친구 요청을 보낼 수 있어요!');
76-
return;
77-
}
7862
const matchingRequestData = {
7963
requesterId: my_id,
8064
targetId: userDetails.userId,
@@ -88,12 +72,7 @@ const UserInfo: React.FC = React.memo(() => {
8872
console.log(response);
8973
} catch (error: any) {
9074
console.error('친구 신청 오류:', error);
91-
if (error.response?.data?.message === '이미 요청한 관계입니다.') {
92-
setFriend(false);
93-
handleModalOpen('이미 친구 신청을 보냈습니다!');
94-
} else {
95-
handleModalOpen('친구 신청에 실패했습니다.\n다시 시도해 주세요.');
96-
}
75+
handleModalOpen(error.response?.data?.message);
9776
}
9877
};
9978

@@ -167,7 +146,7 @@ const UserInfo: React.FC = React.memo(() => {
167146
<>
168147
<img src={HeartSvg} alt="heart icon" />
169148
<StyledText $textTheme={{ style: 'body1-medium' }} color={theme.colors.white}>
170-
친구 신청
149+
매칭 요청
171150
</StyledText>
172151
</>
173152
)}

0 commit comments

Comments
 (0)