From 0aac51f2337c889f50d05061c4c88de23760e3d3 Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Fri, 7 Feb 2025 19:18:30 +0000 Subject: [PATCH] Update regex to replace the url correctly --- aws/lambdas/auth/authorizer/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/lambdas/auth/authorizer/index.ts b/aws/lambdas/auth/authorizer/index.ts index 1f6e0fe0..1ad5b517 100644 --- a/aws/lambdas/auth/authorizer/index.ts +++ b/aws/lambdas/auth/authorizer/index.ts @@ -80,8 +80,8 @@ const generatePolicy = ( { Action: "execute-api:Invoke", Effect: effect, - // Replaces resource (Http Method and path) with wildcard to take advantage of caching - Resource: resource.replace(/\/[^/]+$/, "/*"), + // Replace everything after stage with wildcard + Resource: resource.replace(/(.*?\/\w+)\/.*/, "$1/*"), }, ], };