From 7d3a9e22257697b93e27f008ff3e16e06dbb1f39 Mon Sep 17 00:00:00 2001 From: "selvendran.ayyaswamy" Date: Wed, 28 Jul 2021 16:55:22 +0530 Subject: [PATCH] fix: When custom resources are created on api gateway and mapped with the NestJS proxy, it was not working as expected. The fix is made to address that issue --- src/event-sources/utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/event-sources/utils.js b/src/event-sources/utils.js index 5db4ecbd..bf58ec75 100644 --- a/src/event-sources/utils.js +++ b/src/event-sources/utils.js @@ -3,8 +3,12 @@ const url = require('url') function getPathWithQueryStringParams ({ event, query = event.multiValueQueryStringParameters, - // NOTE: Use `event.pathParameters.proxy` if available ({proxy+}); fall back to `event.path` - path = (event.pathParameters && event.pathParameters.proxy && `/${event.pathParameters.proxy}`) || event.path, + // NOTE: Always use event.path, if the API gateway has custom route setup, for example if my controllers path is + // something like employee/services/service1, employee/services/service2 etc, if I dont have any custom path/resources setup + // and directly have root/{proxy+} it works as expected, if i have a resource like /employee and child to that if there + // is a resource like {proxy+} it is not working as expected and errors out with 404. This change is required to address that + // specific issue. + path = event.path, // NOTE: Strip base path for custom domains stripBasePath = '', replaceRegex = new RegExp(`^${stripBasePath}`)