|
1 | 1 | import { webPath } from '@router/index'; |
| 2 | +import { MESSAGE_TYPES } from '../../config/webview'; |
2 | 3 |
|
3 | 4 | const baseURL = import.meta.env.VITE_BASE_URL; |
4 | 5 | const Headers = { 'Content-Type': 'application/json' } as const; |
@@ -72,11 +73,11 @@ const fetchAuthData = async (path: string, init: RequestInit = {}, isFormData: b |
72 | 73 | window.dispatchEvent(new CustomEvent('localStorageChange', { detail: { key: 'access_token' } })); |
73 | 74 | window.dispatchEvent(new CustomEvent('localStorageChange', { detail: { key: 'refresh_token' } })); |
74 | 75 |
|
75 | | - (window as any).ReactNativeWebView?.postMessage(JSON.stringify({ type: 'TOKEN', token: access_token })); |
76 | | - // const token = localStorage.getItem('access_token'); |
77 | | - // if (token && window.ReactNativeWebView) { |
78 | | - // window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'TOKEN', token })); |
79 | | - // } |
| 76 | + // WebView에 새 토큰 전달 |
| 77 | + (window as any).ReactNativeWebView?.postMessage( |
| 78 | + JSON.stringify({ type: MESSAGE_TYPES.TOKEN, token: access_token }), |
| 79 | + ); |
| 80 | + |
80 | 81 | // 원래 요청 재시도 |
81 | 82 | res = await fetch(url, { |
82 | 83 | method: 'GET', |
@@ -104,10 +105,4 @@ const fetchAuthData = async (path: string, init: RequestInit = {}, isFormData: b |
104 | 105 | return data; |
105 | 106 | }; |
106 | 107 |
|
107 | | -// function getCookie(name: string) { |
108 | | -// const value = `; ${document.cookie}`; |
109 | | -// const parts = value.split(`; ${name}=`); |
110 | | -// if (parts.length === 2) return parts.pop()?.split(';').shift(); |
111 | | -// } |
112 | | - |
113 | 108 | export { baseURL, Headers, wait, enableMock, fetchData, fetchAuthData }; |
0 commit comments