import { defineMiddleware } from "astro/middleware" import { validateAuth } from '../libs/validateAuth' // `context` and `next` are automatically typed export default defineMiddleware(async (context, next) => { if (!context.request.url.includes('api')) { return next() } const auth = await validateAuth(context.request, { name: 'slicing.slice', api: true, cookie: true }) if (typeof auth === 'object') { return auth } context.locals.authKey = auth return next() })