// src/middleware.ts import { clerkMiddleware, createRouteMatcher } from '@clerk/astro/server'; import type { AstroMiddlewareRequest, AstroMiddlewareResponse } from 'astro'; const isProtectedRoute = createRouteMatcher([ '/pokemon', ]); export const onRequest = clerkMiddleware((auth, context) => { if (!auth().userId && isProtectedRoute(context.request)) { // Redirect unauthenticated users to the sign-in page return auth().redirectToSignIn(); } });