fix: add auth headers to loadCanvas, add canvas import

This commit is contained in:
2026-04-24 01:42:35 +05:00
parent ade67c0221
commit f9e35cb9e7
+10 -1
View File
@@ -64,14 +64,23 @@ export const useCanvas = () => {
return { nodes, edges } return { nodes, edges }
} }
const getAuthHeaders = (): Record<string, string> => {
const auth = useAuth()
const token = auth.token?.value
return token ? { Authorization: `Bearer ${token}` } : {}
}
const loadCanvas = async (id: string): Promise<CanvasData> => { const loadCanvas = async (id: string): Promise<CanvasData> => {
const data = await $fetch(`/api/canvas/${id}`) const data = await $fetch(`/api/canvas/${id}`, {
headers: getAuthHeaders()
})
return parseCanvasJson(data) return parseCanvasJson(data)
} }
const updateNodeState = async (nodeId: string, state: string) => { const updateNodeState = async (nodeId: string, state: string) => {
return await $fetch(`/api/nodes/${nodeId}`, { return await $fetch(`/api/nodes/${nodeId}`, {
method: 'PUT', method: 'PUT',
headers: getAuthHeaders(),
body: { state } body: { state }
}) })
} }