fix 100% height header and added auth to /pokemon
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
import { clerkMiddleware } from "@clerk/astro/server";
|
||||
// src/middleware.ts
|
||||
import { clerkMiddleware, createRouteMatcher } from '@clerk/astro/server';
|
||||
import type { AstroMiddlewareRequest, AstroMiddlewareResponse } from 'astro';
|
||||
|
||||
export const onRequest = clerkMiddleware();
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user