import { useFetch, useRuntimeConfig } from '#imports'; export const useApi = ( path: string, options: { method?: 'get' | 'post' | 'put' | 'delete' body?: any query?: Record headers?: HeadersInit server?: boolean // ← 이 줄 추가! } = {} ) => { const userStore = useUserStore(); const config = useRuntimeConfig(); const method = options.method ? options.method.toUpperCase() : 'GET' return useFetch(() => `${config.public.apiBase}${config.public.contextPath}${path}`, { method: method as any, // 타입 강제 우회 body: options.body, query: options.query, headers: { Authorization: 'Bearer ' + userStore.getToken, ...options.headers, }, onResponse({response}){ const accessToken = response.headers.get("Authorization") || ""; userStore.setToken(accessToken.replace("Bearer ", "")); }, server: options.server // ← 이 줄 추가! }) }