[FA-misc] Switches to using DTOs, updates frontend with details and reader page, updates novel import to be an upsert
This commit is contained in:
22
fictionarchive-web-astro/src/middleware.ts
Normal file
22
fictionarchive-web-astro/src/middleware.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineMiddleware } from 'astro:middleware';
|
||||
|
||||
const STATIC_PATHS = ['/_astro/', '/favicon.svg', '/favicon.ico'];
|
||||
|
||||
export const onRequest = defineMiddleware(async (context, next) => {
|
||||
const { request, url } = context;
|
||||
|
||||
// Bypass auth for static assets
|
||||
if (STATIC_PATHS.some((p) => url.pathname.startsWith(p))) {
|
||||
return next();
|
||||
}
|
||||
|
||||
// Simple presence check for fa_session cookie
|
||||
const cookieHeader = request.headers.get('cookie') || '';
|
||||
const hasSession = /fa_session=[^;]+/.test(cookieHeader);
|
||||
|
||||
if (hasSession) {
|
||||
return next();
|
||||
}
|
||||
|
||||
return context.rewrite('/gated-404');
|
||||
});
|
||||
Reference in New Issue
Block a user