export default defineNuxtPlugin(() => { const route = useRoute() const baseFetch = globalThis.$fetch ?? $fetch globalThis.$fetch = baseFetch.create({ onResponseError({ response, request }) { if (response?.status !== 401) return const url = typeof request === 'string' ? request : request?.url ?? '' if (!url.startsWith('/')) return const redirect = (route.fullPath && route.fullPath !== '/' ? route.fullPath : '/') navigateTo({ path: '/login', query: { redirect } }, { replace: true }) }, }) })