From 74c515c97e560d18d4d30752d95a98fb17949ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=9A=E7=AA=97=E5=90=AC=E9=9B=A8=E4=B8=BF=E9=86=89?= =?UTF-8?q?=E6=97=A0=E5=BF=83?= <994039348@qq.com> Date: Tue, 8 Oct 2024 12:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=89=20Token=20=E6=97=B6,=20=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B4=E6=89=8D=E6=90=BA=E5=B8=A6=20Token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/01.fetch-interceptors.client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/plugins/01.fetch-interceptors.client.ts b/app/plugins/01.fetch-interceptors.client.ts index d4174a4..b073491 100644 --- a/app/plugins/01.fetch-interceptors.client.ts +++ b/app/plugins/01.fetch-interceptors.client.ts @@ -14,7 +14,8 @@ export default defineNuxtPlugin((nuxtApp) => { const headers = options.headers ??= {}; // 请求头携带 Token - addFetchHeader(headers, 'Authorization', `Bearer ${accessToken.value}`); + if (accessToken.value) + addFetchHeader(headers, 'Authorization', `Bearer ${accessToken.value}`); // 设置默认响应数据类型 options.responseType ??= 'json';