NodeJS
타입스크립트에서 jwt.sign 에러
liufeier
2022. 1. 22. 17:23
반응형
https://stackoverflow.com/questions/66328425/jwt-argument-of-type-string-undefined-is-not-assignable-to-parameter-of-typ
타입스크립트에선 dotenv로 불러온 데이터를 undefined로 인식하는 것 같다
스트링으로 인식하게 바꾸면 일단은 해결이 된다
const token = jwt.sign({ id: user.id }, process.env.SECRET_KEY || "");
또는
const token = jwt.sign({ id: user.id }, String(process.env.SECRET_KEY));
반응형