From e7b5faf6fae9879bf2d5093c071b7c01f5b4ca01 Mon Sep 17 00:00:00 2001 From: Amit Moryossef Date: Mon, 21 Oct 2024 22:43:20 +0200 Subject: [PATCH] fix(ratelimit): invoke value during runtime --- functions/src/middlewares/unkey-ratelimit.middleware.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/src/middlewares/unkey-ratelimit.middleware.ts b/functions/src/middlewares/unkey-ratelimit.middleware.ts index c8930c41..7b3eec2d 100644 --- a/functions/src/middlewares/unkey-ratelimit.middleware.ts +++ b/functions/src/middlewares/unkey-ratelimit.middleware.ts @@ -15,15 +15,15 @@ export function rateLimitHeaders(res: Response, ratelimitResponse: RatelimitResp } export function unkeyRatelimit(namespace: string, limit: number, duration: Duration) { - const unkeyRootKey = defineString('UNKEY_ROOT_KEY').value(); + const unkeyRootKey = defineString('UNKEY_ROOT_KEY'); return async function (req: Request, res: Response, next: NextFunction) { const rawIdentifier = requestIp.getClientIp(req) ?? 'unknown'; - const saltedIdentifier = rawIdentifier + unkeyRootKey; + const saltedIdentifier = rawIdentifier + unkeyRootKey.value(); const identifier = createHash('sha256').update(saltedIdentifier).digest('hex'); const rateLimit = new Ratelimit({ - rootKey: unkeyRootKey, + rootKey: unkeyRootKey.value(), namespace, limit, duration,