Skip to content

Commit

Permalink
[fix] 빌드 과정 중 eslint 에러 뜨는 거 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
choihooo committed Oct 12, 2024
1 parent b4066cc commit 856c71d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 77 deletions.
6 changes: 0 additions & 6 deletions fe/src/app/api/auth/callback/kakao/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ export async function GET(req: NextRequest) {

const accessToken = tokenData.access_token;

// 액세스 토큰 출력 (테스트 용도)
// console.log('Access Token:', accessToken); // eslint-disable-line no-console

// 클라이언트에 액세스 토큰 전달
return NextResponse.json({ accessToken });
} catch (error) {
// eslint-disable-line no-console
console.error("Error during OAuth process:", error);
return NextResponse.json(
{ error: "Internal server error" },
{ status: 500 }
Expand Down
73 changes: 3 additions & 70 deletions fe/src/app/api/auth/callback/naver/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function GET(req: NextRequest) {
if (!code || !clientId || !clientSecret || !redirectUri) {
return NextResponse.json(
{ error: "Missing required parameters" },
{ status: 400 },
{ status: 400 }
);
}

Expand All @@ -22,15 +22,15 @@ export async function GET(req: NextRequest) {
{
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
},
}
);

const tokenData = await tokenResponse.json();

if (tokenData.error) {
return NextResponse.json(
{ error: tokenData.error_description },
{ status: 400 },
{ status: 400 }
);
}

Expand All @@ -42,70 +42,3 @@ export async function GET(req: NextRequest) {
// 프론트엔드에서 액세스 토큰을 확인할 수 있도록 응답
return NextResponse.json({ accessToken });
}

// 백엔드와 연동 후 사용 예정 코드
/*
import { NextRequest, NextResponse } from "next/server";
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const code = searchParams.get("code");
const state = searchParams.get("state");
const clientId = process.env.NEXT_PUBLIC_NAVER_CLIENT_ID;
const clientSecret = process.env.NEXT_PUBLIC_NAVER_CLIENT_SECRET;
const redirectUri = process.env.NEXT_PUBLIC_REDIRECT_URI;
console.log("Code:", code);
console.log("State:", state);
console.log("Client ID:", clientId);
console.log("Client Secret:", clientSecret);
console.log("Redirect URI:", redirectUri);
if (!code || !clientId || !clientSecret || !redirectUri) {
return NextResponse.json(
{ error: "Missing required parameters" },
{ status: 400 }
);
}
try {
const tokenResponse = await fetch(
`https://nid.naver.com/oauth2.0/token?grant_type=authorization_code&client_id=${clientId}&client_secret=${clientSecret}&code=${code}&state=${state}`,
{
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
}
);
const tokenData = await tokenResponse.json();
console.log("Token Data:", tokenData);
if (tokenData.error) {
return NextResponse.json(
{ error: tokenData.error_description },
{ status: 400 }
);
}
const accessToken = tokenData.access_token;
const backendResponse = await fetch("http://localhost:8080/api/auth/naver", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token: accessToken }),
});
if (backendResponse.ok) {
return NextResponse.redirect("/dashboard");
} else {
return NextResponse.json(
{ error: "Failed to authenticate with the backend" },
{ status: 500 }
);
}
} catch (error) {
console.error("Error during OAuth process:", error);
return NextResponse.json({ error: "Internal server error" }, { status: 500 });
}
}
*/
2 changes: 1 addition & 1 deletion fe/src/app/component/NaverLoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function NaverLoginButton() {
}

const naverAuthUrl = `https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=${clientId}&redirect_uri=${encodeURIComponent(
redirectUri,
redirectUri
)}&state=${state}`;

window.location.href = naverAuthUrl;
Expand Down

0 comments on commit 856c71d

Please sign in to comment.