인프런 커뮤니티 질문&답변

Heeeyaaa님의 프로필 이미지

작성한 질문수

[최신] Vue 강의 끝판왕 : Nuxt 3 완벽 마스터

Server Auth Utils & Middleware

config.authCookieName 에서 타입 오류가 발생합니다.

24.07.02 15:40 작성

·

76

0

  • [vue-tsc] Argument of type 'unknown' is not assignable to parameter of type 'string'.
    /workspace/dev/nuxt-tutorial/server/routes/auth/login.post.ts:38:20
        36 |
        37 |   const config = useRuntimeConfig();
      > 38 |   setCookie(event, config.authCookieName, JSON.stringify(userWithoutPassword));
           |                    ^^^^^^^^^^^^^^^^^^^^^
        39 |
        40 |   return {
        41 |     user: userWithoutPassword,
  • [vue-tsc] Argument of type 'unknown' is not assignable to parameter of type 'string'.

    /workspace/dev/nuxt-tutorial/server/utils/auth.ts:5:43
        3 | export function getUserFromEvent(event: H3Event) {
        4 |   const config = useRuntimeConfig();
      > 5 |   const userJsonString = getCookie(event, config.authCookieName);
          |                                           ^^^^^^^^^^^^^^^^^^^^^
        6 |
        7 |   console.log('userJsonString: ', userJsonString);

config.authCookieName 

에서 타입 오류가 발생하는데 어떻게 해결 할 수 있을까요..?

답변 1

0

짐코딩님의 프로필 이미지
짐코딩
지식공유자

2024. 07. 02. 20:28

안녕하세요 😀

RuntimeConfig Type 관련해서 아래 링크를 참고하시면 될 것 같습니다.

https://nuxt.com/docs/guide/going-further/runtime-config#typing-runtime-config

Heeeyaaa님의 프로필 이미지

작성한 질문수

질문하기