Skip to content

Commit fbbd32c

Browse files
authored
Merge pull request #441 from getlift/empty-domain
fix: use normalized domains in getMainCustomDomain()
2 parents 0f5475a + d502bf3 commit fbbd32c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/constructs/aws/ServerSideWebsite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ export class ServerSideWebsite extends AwsConstruct {
349349
}
350350

351351
getMainCustomDomain(): string | undefined {
352-
if (this.configuration.domain === undefined) {
352+
if (this.domains === undefined || this.domains.length === 0) {
353353
return undefined;
354354
}
355355

356356
// In case of multiple domains, we take the first one
357-
return typeof this.configuration.domain === "string" ? this.configuration.domain : this.configuration.domain[0];
357+
return this.domains[0];
358358
}
359359

360360
private createCacheBehaviors(bucket: Bucket): Record<string, BehaviorOptions> {

test/unit/serverSideWebsite.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,13 @@ describe("server-side website", () => {
631631
expect(cfTemplate.Resources[cfDistributionLogicalId]).not.toHaveProperty(
632632
"Properties.DistributionConfig.ViewerCertificate"
633633
);
634+
// The domain output should fall back to the CloudFront domain
635+
expect(cfTemplate.Outputs).toMatchObject({
636+
[computeLogicalId("backend", "Domain")]: {
637+
Description: "Website domain name.",
638+
Value: { "Fn::GetAtt": [cfDistributionLogicalId, "DomainName"] },
639+
},
640+
});
634641
});
635642

636643
it("should treat empty string domain with valid certificate as unconfigured", async () => {

0 commit comments

Comments
 (0)