Skip to content

Commit 2cb468c

Browse files
authored
Merge pull request #189 from codeit-plake/refactor/164-auth-review-opt
[#164]fix: 로그인 이슈 해결
2 parents 341124b + bb4544c commit 2cb468c

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

src/actions/user-check-action.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
"use server";
22

33
import { IUser } from "@/types/user";
4-
import { getCookieOfToken } from "@/utils/cookieToken";
5-
6-
const userCheckAction = async () => {
7-
const TOKEN = await getCookieOfToken();
84

5+
const userCheckAction = async (token: string) => {
96
try {
107
const response = await fetch(
118
`${process.env.NEXT_PUBLIC_API_URL}/auths/user`,
129
{
1310
method: "GET",
1411
headers: {
15-
Authorization: `Bearer ${TOKEN}`,
12+
Authorization: `Bearer ${token}`,
1613
},
1714
},
1815
);
1916

20-
// 유저 정보 확인 실패
2117
if (!response.ok) {
2218
throw new Error(await response.text());
2319
}
2420

25-
// 유저 정보 확인 성공 시 image null 처리
21+
// 유저 정보 받아와서 image null 처리
2622
const resUser: IUser = await response.json();
2723
resUser.image = resUser.image || "";
28-
2924
return {
3025
status: true,
3126
user: resUser,

src/actions/user-signin-action.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"use server";
22

3-
import { setCookieOfToken } from "@/utils/cookieToken";
4-
53
import userCheckAction from "./user-check-action";
64

75
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
@@ -23,24 +21,25 @@ const userSignInAction = async (_: any, formData: FormData) => {
2321
},
2422
);
2523

26-
// 로그인 실패
24+
// 토큰 받아오기 실패
2725
if (!response.ok) {
28-
throw new Error(await response.text());
26+
const errorText = await response.text();
27+
console.error("API 응답 오류:", errorText);
28+
throw new Error(errorText);
2929
}
3030

3131
// 토큰을 받아오면 쿠키에 저장
3232
const res = await response.json();
33-
await setCookieOfToken(res.token);
3433

35-
// 로그인 성공 시 유저 정보 확인
36-
const chkResult = await userCheckAction();
34+
// 유저 정보 확인
35+
const chkResult = await userCheckAction(res.token);
3736

38-
// 유저 정보 확인 실패
37+
// 유저 정보 확인 성공
3938
if (!chkResult.status) {
4039
throw new Error(chkResult.error);
4140
}
4241

43-
// 유저 정보 반환
42+
// 성공시 유저 정보 반환
4443
return {
4544
status: true,
4645
error: "",

src/actions/user-signup-action.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ const userSignUpAction = async (_: any, formData: FormData) => {
2121
},
2222
);
2323

24-
// 회원가입 실패
2524
if (!response.ok) {
2625
throw new Error(await response.text());
2726
}
2827

29-
// 회원가입 성공
3028
return {
3129
status: true,
3230
error: "",

src/app/all-reviews/[tab]/_components/ReviewListParent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const ReviewListParent = () => {
5454
<ReviewCardList reviews={flatData} />
5555
<div ref={setTarget} className="h-10 w-full">
5656
{isFetchingNextPage && (
57-
<div className="flex justify-center p-4">
57+
<div className="flex justify-center py-8">
5858
<LoadingSpinner size="lg" />
5959
</div>
6060
)}

src/app/layout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ export default function RootLayout({
2121
}>) {
2222
return (
2323
<html lang="en">
24+
<head>
25+
<link
26+
rel="preconnect"
27+
href="https://fe-adv-project-together-dallaem.vercel.app"
28+
/>
29+
<link
30+
rel="preconnect"
31+
href="https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/together-dallaem"
32+
/>
33+
</head>
2434
<body className={`${FONT.variable} antialiased`} suppressHydrationWarning>
2535
<QueryProvider>
2636
<Header />

src/components/layout/ReviewCardItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ReviewCardItem = memo(({ review }: TReviewCardItemProps) => {
3030
href={`/gathering/detail/${Gathering.id}`}
3131
style={{ display: "contents" }}
3232
>
33-
<div className="relative min-h-[156px] w-full max-w-[280px] overflow-hidden rounded-3xl">
33+
<div className="relative min-h-[156px] w-full overflow-hidden rounded-3xl md:max-w-[280px]">
3434
<Image
3535
src={Gathering.image ?? "https://picsum.photos/500/700"}
3636
alt={Gathering.name}

0 commit comments

Comments
 (0)