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;
}
