update api auth
All checks were successful
deploy / build-and-deploy (push) Successful in 15s

This commit is contained in:
2025-10-15 13:15:24 +02:00
parent 94c86a1183
commit d3af1cedfd
5 changed files with 15 additions and 8 deletions

7
src/util/auth.ts Normal file
View File

@@ -0,0 +1,7 @@
import { API_SECRET } from 'astro:env/server';
const BASIC_AUTH_HEADER = API_SECRET ? `Basic ${Buffer.from(`api:${API_SECRET}`).toString('base64')}` : null;
export function checkApiBasicAuth(headers: Headers) {
return BASIC_AUTH_HEADER ? headers.get('authorization') === BASIC_AUTH_HEADER : true;
}