Skip to content

Commit

Permalink
有 Token 时, 请求头才携带 Token
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhang-Wei-666 committed Oct 8, 2024
1 parent 23830c0 commit 74c515c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/plugins/01.fetch-interceptors.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 74c515c

Please sign in to comment.