diff --git a/src/apis/login.js b/src/apis/login.js new file mode 100644 index 0000000..9255bd1 --- /dev/null +++ b/src/apis/login.js @@ -0,0 +1,9 @@ +import { authAxios, testAxios } from '../axios'; + +// 로그인 +export const kakaoLoginAPI = async () => { + const response = await testAxios.get(`/login`); + // const loginUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=856122255feeea21d537c0225f6c658a&redirect_uri=http://localhost:8080/auth/kakao/callback`; + const loginUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=856122255feeea21d537c0225f6c658a&redirect_uri=https://wellet.store/auth/kakao/callback`; + window.location.href = loginUrl; +}; diff --git a/src/axios/index.js b/src/axios/index.js index 41a04e7..ee4f196 100644 --- a/src/axios/index.js +++ b/src/axios/index.js @@ -10,6 +10,15 @@ export const authAxios = axios.create({ }, }); +export const testAxios = axios.create({ + // baseURL: "http://localhost:8080", + baseURL: 'https://wellet.store', + withCredentials: true, + headers: { + 'Content-Type': 'application/json', + }, +}); + const getTokenFromCookie = () => { // const cookie = document.cookie // .split('; ') @@ -18,8 +27,7 @@ const getTokenFromCookie = () => { return dummyToken; }; -const dummyToken = - 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIzODQ1Njk3MjEwIiwicm9sZSI6IlVTRVIiLCJuaWNrbmFtZSI6Iuq5gO2YnOumvCIsImlkIjozODQ1Njk3MjEwLCJleHAiOjE3MzQ4Nzk5ODIsImlhdCI6MTczNDg3NjM4MiwidXNlcm5hbWUiOiIwMTVmZDUwNy0zNWJiLTQxNmYtYjQ4OC03Y2JiN2NjYTQ0NjQifQ.Glv2-tcXLiqhI3TasBvC9WmS9P7YE7-AC1RnS9gzl_x0hfBxW5jfcTvsqBS7D6o40rbBKUPU8Iscvs1PsDiB2g'; +const dummyToken = '토큰값'; // 요청을 보낼 때 Bearer Token을 Authorization 헤더에 추가합니다. authAxios.interceptors.request.use( (config) => { diff --git a/src/pages/LoginPage/LoginPage.jsx b/src/pages/LoginPage/LoginPage.jsx index b9b45aa..c8dd1be 100644 --- a/src/pages/LoginPage/LoginPage.jsx +++ b/src/pages/LoginPage/LoginPage.jsx @@ -5,9 +5,21 @@ import login_background_lines from '../../assets/images/login_background_lines.s import { PrimaryButton, SecondaryButton } from '../../components'; import { useNavigate } from 'react-router-dom'; +// import { kakaoLoginAPI, getUserInfo } from '../../apis/login'; +import { kakaoLoginAPI } from '../../apis/login'; + export default function LoginPage() { const navigate = useNavigate(); + async function kakaoLogin() { + try { + const response = await kakaoLoginAPI(); // 카카오 로그인 API 호출 + } catch (error) { + // 로그인 실패 시 처리 + alert('로그인 실패. 다시 시도.' + error); + } + } + return ( navigate('/home')} + // onClick={() => navigate('/home')} + // onClick={() => kakaoLogin } + onClick={kakaoLogin} >