axiosでトークン取得を修正する

This commit is contained in:
Mouriya
2024-08-08 15:48:33 +09:00
parent 4a4a9d72e6
commit 7e6143cac7

View File

@@ -16,7 +16,7 @@ declare module '@vue/runtime-core' {
// "export default () => {}" function below (which runs individually
// for each client)
const api:AxiosInstance = axios.create({ baseURL: process.env.KAB_BACKEND_URL });
const token=JSON.parse(localStorage.getItem('auth') ?? '{}')?.token||'';
const token=JSON.parse(localStorage.getItem('auth') ?? '{}')?.token ?? '';
if(token!==''){
api.defaults.headers["Authorization"]='Bearer ' + token;
}