Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
TypeScript
12345678910111213141516171819/** * Sends the browser back through `/login` when an `/api/admin` call reports * that the OAuth session is gone, instead of leaving the page rendering * empty state. A full page load is used so the server middleware can * re-issue the authorize redirect. */export default defineNuxtPlugin(() => { globalThis.$fetch = $fetch.create({ onResponseError ({ request, response }) { if (response.status !== 401) return
const url = typeof request === 'string' ? request : request.url if (!url.includes('/api/admin/')) return
window.location.href = '/login' }, })})