This commit is contained in:
mrfelfel
2026-07-18 19:41:33 +03:30
parent 87ba0d253d
commit dfb0e857f1
158 changed files with 20278 additions and 0 deletions

16
dist/server/chunks/apiAuth_DcNSM7D5.mjs vendored Normal file
View File

@@ -0,0 +1,16 @@
const getToken = () => "admin123";
const requireApiToken = (context) => {
const authorization = context.request.headers.get("authorization") ?? "";
const headerToken = context.request.headers.get("x-api-key") ?? "";
const bearerToken = authorization.startsWith("Bearer ") ? authorization.slice(7) : "";
const token = bearerToken || headerToken;
if (token !== getToken()) {
return new Response(JSON.stringify({ error: "Unauthorized" }), {
status: 401,
headers: { "content-type": "application/json; charset=utf-8" }
});
}
return null;
};
export { requireApiToken as r };