From c5f2c19c3c4cb849ae665d589e53048ef1152928 Mon Sep 17 00:00:00 2001 From: Johannes Waigel Date: Sun, 8 Sep 2024 21:59:40 +0200 Subject: [PATCH] fix: use rpc client in middleware to avoide workerd issues (#25) --- packages/permify/src/middleware.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/permify/src/middleware.ts b/packages/permify/src/middleware.ts index bebb85e..c489962 100644 --- a/packages/permify/src/middleware.ts +++ b/packages/permify/src/middleware.ts @@ -92,8 +92,6 @@ export function createCheckPermissionMiddleware(options: MiddlewareOptions): { throwOnPermissionDenied = true, } = options; - const client = permify.grpc.newClient(options.client); - return { checkPermission: ({ entity, @@ -103,6 +101,9 @@ export function createCheckPermissionMiddleware(options: MiddlewareOptions): { tinyassert(entity, "entity is required"); tinyassert(entity.id, "entity.id is required"); tinyassert(entity.type, "entity.type is required"); + + const client = permify.grpc.newClient(options.client); + // Get the tenant ID from the context variable or use the default tenant ID const requestTenantId = tenantIdContextVariable && ctx.get(tenantIdContextVariable)