[에러] 시간 설정

옥수수의 코딩이야기·2023년 2월 12일
0

에러

목록 보기
14/18
post-thumbnail

문제: '클론코딩으로 시작하는 Next.js' 라는 책을 따라가다가 발견한 문제
Invalid character in header content ["Set-Cookie"]...

해결방안

 // Cookie Expire Time Set
        var expires = new Date();
        const koreaTimeDiff = 9 * 60 * 60 * 1000; 
		// 한국 시간은 UTC보다 9시간 빠름(9시간의 밀리세컨드 표현)
        expires.setTime(expires.getTime() + koreaTimeDiff + 30 * 60 * 1000);

        const token = jwt.sign(String(newUser.id), process.env.JWT_SECRET);
        res.setHeader("Set-Cookie",
            `access_token=${token}; path=/; expires=${expires.toUTCString()}); httponly`);

참고
https://merrily-code.tistory.com/162

profile
프론트엔드 공부중 기억은 블로그가 대신합니다.

0개의 댓글