From f9e35cb9e7b1389b9df5d328864ef8b1bdc473ed Mon Sep 17 00:00:00 2001 From: AlexIves16 Date: Fri, 24 Apr 2026 01:42:35 +0500 Subject: [PATCH] fix: add auth headers to loadCanvas, add canvas import --- app/composables/useCanvas.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/composables/useCanvas.ts b/app/composables/useCanvas.ts index ec638d6..669f37e 100644 --- a/app/composables/useCanvas.ts +++ b/app/composables/useCanvas.ts @@ -64,14 +64,23 @@ export const useCanvas = () => { return { nodes, edges } } + const getAuthHeaders = (): Record => { + const auth = useAuth() + const token = auth.token?.value + return token ? { Authorization: `Bearer ${token}` } : {} + } + const loadCanvas = async (id: string): Promise => { - const data = await $fetch(`/api/canvas/${id}`) + const data = await $fetch(`/api/canvas/${id}`, { + headers: getAuthHeaders() + }) return parseCanvasJson(data) } const updateNodeState = async (nodeId: string, state: string) => { return await $fetch(`/api/nodes/${nodeId}`, { method: 'PUT', + headers: getAuthHeaders(), body: { state } }) }