Skip to content

Commit 20fb9c4

Browse files
committed
feat: allow stats access from nedaa.dev without admin key
1 parent 0f6f886 commit 20fb9c4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/modules/stats/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export const statsModule = new Elysia({
2020
query: StatsPeriodQuery,
2121
response: StatsSummaryResponse,
2222
beforeHandle({ headers }) {
23-
if (headers["x-admin-key"] !== env.ADMIN_API_KEY) {
23+
const origin = headers.origin ?? "";
24+
const isNedaa =
25+
origin === "https://nedaa.dev" || origin === "https://www.nedaa.dev";
26+
const isAdmin = headers["x-admin-key"] === env.ADMIN_API_KEY;
27+
28+
if (!isNedaa && !isAdmin) {
2429
throw new AppError("Unauthorized", 401, CODES.UNAUTHORIZED);
2530
}
2631
},

0 commit comments

Comments
 (0)