export default defineNuxtRouteMiddleware(async (to) => {
  // Only protect admin routes (except login)
  if (!to.path.startsWith('/admin') || to.path === '/admin/login') return

  try {
    await $fetch('/api/admin/auth/check')
  }
  catch {
    return navigateTo('/admin/login')
  }
})
