Skip to content

Commit

Permalink
✨ Feat(#113): 쿠키 저장 함수 추가 외 2건
Browse files Browse the repository at this point in the history
- React Strict mode false
- API 요청 에러 검증 조건 수정
  • Loading branch information
sscoderati committed Nov 6, 2023
1 parent b1d10b0 commit 1655544
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const nextConfig = {
eslint: {
dirs: ["src"],
},
reactStrictMode: false,
};

module.exports = nextConfig;
4 changes: 3 additions & 1 deletion src/components/_common/Modal/LoginModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const LoginModal = ({ trigger }: PropsWithChildren<{ trigger: ReactNode }>) => {
const authCode = params.get("code");
if (authCode) {
getKakaoToken(authCode).then((res) => {
if (authCode && res.isNew === true) {
// const { id, isNew, token } = res;

if (authCode && res.isNew === false) {
setSteps(1);
setOpen(true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/oauth/kakao/getKakaoLoginURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { baseInstance } from "@/services";
const getKakaoLoginUrl = async () => {
try {
const response = await baseInstance.get("api/v1/auth/kakao");
if (response.status !== 200) {
if (!(response.status / 100 === 2)) {
throw new Error("Failed to fetch kakao url!");
}
return response.headers.location;
Expand Down
2 changes: 1 addition & 1 deletion src/services/oauth/kakao/getKakaoToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const getKakaoToken = async (code: string) => {
const response = await baseInstance.get(
`/api/v1/auth/kakao/callback?code=${code}`,
);
if (response.status !== 200) {
if (!(response.status / 100 === 2)) {
throw new Error("Failed to fetch kakao token!");
}
return response.data;
Expand Down
12 changes: 12 additions & 0 deletions src/utils/setCookie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use server";

import { cookies } from "next/headers";

interface tokenType {
accessToken: string;
refreshToken: string;
}

export const create = async (data: tokenType) => {
cookies().set("jwt", `${data}`, { maxAge: 30 });
};

0 comments on commit 1655544

Please sign in to comment.