From 6f72d9d16a633cbbd20f7374bb4895cf092f0512 Mon Sep 17 00:00:00 2001 From: Vlad <0vvland@gmail.com> Date: Sun, 7 Apr 2024 11:07:56 +0300 Subject: [PATCH] Fix domain deleting when fail on not exist stack When stack not exists `findApiId()` fails on `getStack()` and then on `getNestedStack()`. Try block in `removeBasePathMappings()` do not set `externalBasePathExists` flag. As result domain that has other mappings are removed. This fix adds extra check to catch block of `removeBasePathMappings()` if option `preserveExternalPathMappings` is set in stack config (by setting this option user identify that domain should have another mappings) and set the flag `externalBasePathExists` that prevent removing domain. --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 258d9bf8..5c3d982a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -408,6 +408,9 @@ class ServerlessCustomDomain { `Unable to remove base path mappings for '${domain.givenDomainName}':\n${err.message}` ); } + if (domain.preserveExternalPathMappings) { + externalBasePathExists = true; + } } if (domain.autoDomain === true && !externalBasePathExists) {