하관우 하관우 03-24
2025-03-24 하관우 새로고침시 토큰 재발급
@bcb16f26a43acfedf4399e1f27ba6cff6193fcb8
client/views/App.vue
--- client/views/App.vue
+++ client/views/App.vue
@@ -28,7 +28,7 @@
   methods: {
     async refreshToken() {
       try {
-        const res = await apiClient.post("/refresh/tknReissue.json", {}, {
+        const res = await axios.post("/refresh/tknReissue.json", {}, {
           headers: {
             "Content-Type": "application/json; charset=UTF-8",
           },
@@ -36,7 +36,7 @@
 
         if (res.status === 200) {
           // 새로 발급 받은 AccessToken 저장
-          store.commit('setAuthorization', res.headers.authorization);
+          this.store.commit('setAuthorization', res.headers.authorization);
           // JWT 토큰 디코딩
           const base64String = res.headers.authorization.split('.')[1];
           const base64 = base64String.replace(/-/g, '+').replace(/_/g, '/');
@@ -44,8 +44,8 @@
             return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
           }).join(''));
           const mbr = JSON.parse(jsonPayload);
-          store.commit("setUserNm", mbr.userNm); // 사용자 이름 저장
-          store.commit('setRoles', mbr.roles); // 사용자 역할 저장
+          this.store.commit("setUserNm", mbr.userNm); // 사용자 이름 저장
+          this.store.commit('setRoles', mbr.roles); // 사용자 역할 저장
         } else {
           alert('토큰 재발급 요청 실패');
           this.$router.push('/login.page');
@@ -53,7 +53,7 @@
       } catch (error) {
         console.error("Refresh token error:", error);
         alert('세션이 종료되었습니다.\n로그인을 새로 해주세요.');
-        store.commit("setStoreReset");
+        this.store.commit("setStoreReset");
         this.$router.push('/login.page'); // 로그인 페이지로 리다이렉트
       }
     },
Add a comment
List