Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#1/kakao social login setting #8

Merged
merged 8 commits into from
Jul 4, 2024
18 changes: 18 additions & 0 deletions src/app/login/KakaoLogin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const Login = () => {
const REST_API_KEY: string = import.meta.env.REST_API_KEY;
const REDIRECT_URI: string = import.meta.env.REDIRECT_URI;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VITE_ 프리픽스를 앞에 명시해줘야 환경 변수가 잘 동작하지 않나요?! 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네네 맞습니다. 그 부분을 체크 못했네요!! 수정하겠습니다. 감사합니다~

Copy link
Member

@klmhyeonwoo klmhyeonwoo Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const REST_API_KEY: string = import.meta.env.REST_API_KEY;
const REDIRECT_URI: string = import.meta.env.REDIRECT_URI;
const REST_API_KEY: string = import.meta.env.VITE_REST_API_KEY;
const REDIRECT_URI: string = import.meta.env.VITE_REDIRECT_URI;

const link: string = `https://kauth.kakao.com/oauth/authorize?client_id=${REST_API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const link: string = `https://kauth.kakao.com/oauth/authorize?client_id=${REST_API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code`;
const link: string = `https://kauth.kakao.com/oauth/authorize?client_id=${VITE_REST_API_KEY}&redirect_uri=${VITE_REDIRECT_URI}&response_type=code`;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

값이 이미 문자열이라, 타입이 자동 추론돼서 생략해도 될 것 같습니당!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 TS프로젝트가 처음이라... 민희님 말씀대로 추론이 가능한 경우에 생략과 그래도 확실한 명시 중에 어떤 방식이 좋은건가요?? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 추론이 가능한 경우라면 코드 간결성을 위해 생략하는 게 좋다고 생각해요! vscode에서는 변수에 마우스 올리면 타입을 볼 수 있어서 따로 명시하지 않아도 된다고 생각합니다


const loginHandler = () => {
window.location.href = link;
};

return (
<div>
<button type="button" onClick={loginHandler}>
Hello Kakao Login
</button>
</div>
);
};
export default Login;