From c2de8b24c82d78954a94e86267a770c459f90612 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Mon, 27 May 2024 16:09:04 +0800 Subject: [PATCH] fix: token --- pages/search/[id].vue | 1 + utils/fetchEventSource.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/search/[id].vue b/pages/search/[id].vue index ea90342..ac3f94d 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -271,6 +271,7 @@ function initSearchRecords (records) { } async function init () { const { data:responseData, error } = await useRequest(`/v1/chat/${state.id}/history`) + console.log('responseData:', responseData.value) if (error.value) return const { info, records } = responseData.value && responseData.value.data initSearchItemInfo(info) diff --git a/utils/fetchEventSource.js b/utils/fetchEventSource.js index 423f85e..baf4d3f 100644 --- a/utils/fetchEventSource.js +++ b/utils/fetchEventSource.js @@ -1,12 +1,13 @@ import { fetchEventSource } from '@microsoft/fetch-event-source' const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run' export default (url, { onmessage, onerror, controller, params }) => { + const token = useCookie('token') fetchEventSource(`${BASE_URL}${url}`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': '*/*', - 'Authorization': window && window.localStorage && window.localStorage.getItem('token') + 'Authorization': token.value }, body: JSON.stringify(params), onmessage, -- GitLab