Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(website): make legacy chat redirects opt-in (#8004)

teoad563721edee
diff --git a/infra/stacks/website/README.md b/infra/stacks/website/README.md
index b26948bb73..8ec35d4adb 100644
--- a/infra/stacks/website/README.md
+++ b/infra/stacks/website/README.md
@@ -6,6 +6,13 @@ distribution: the public site, `/app` routing to the web-app stack, `/.well-know
OIDC, `resources*` to Ghost, and the `www`/`chat`/signed-in-root redirects in
`wwwRedirect/handler.js`.
+The legacy `chat.macro.com` / `chat-dev.macro.com` redirect hostnames are disabled
+by default. Set `website-infra:enableChatRedirect` to `true` for a stack only after
+its `certArn` covers the corresponding hostname. This enables both the CloudFront
+alias and its Route 53 record; leaving it disabled removes both. CloudFront
+validates every alias against the certificate on distribution updates, so an
+uncovered chat hostname would block unrelated website deploys.
+
Moved from `macro-inc/solid-site/infra`; project and stack names are unchanged,
so this program manages the existing resources.
diff --git a/infra/stacks/website/index.ts b/infra/stacks/website/index.ts
index 7fe3ba8055..6327b87d7a 100644
--- a/infra/stacks/website/index.ts
+++ b/infra/stacks/website/index.ts
@@ -11,6 +11,19 @@ const domain = config.require('domain');
const subdomain = config.require('subdomain');
const domainName = `${subdomain}.${domain}`;
const stack = pulumi.getStack();
+// Every CloudFront alias must be covered by certArn, even for redirect-only hosts.
+const enableChatRedirect = config.getBoolean('enableChatRedirect') ?? false;
+const chatSubdomain = enableChatRedirect
+ ? stack === 'prod'
+ ? 'chat'
+ : stack === 'dev'
+ ? `chat-${subdomain}`
+ : undefined
+ : undefined;
+const aliases = stack === 'prod' ? [domainName, domain] : [domainName];
+if (chatSubdomain) {
+ aliases.push(`${chatSubdomain}.${domain}`);
+}
const staticSiteDir = '../../../apps/marketing/dist';
// The sync never deletes, so an unbuilt dist would "deploy" nothing and still invalidate.
@@ -350,12 +363,7 @@ const cdn = new aws.cloudfront.Distribution(`cdn-${stack}`, {
},
},
priceClass: stack === 'prod' ? 'PriceClass_All' : 'PriceClass_100',
- aliases:
- stack === 'prod'
- ? [domainName, domain, `chat.${domain}`]
- : stack === 'dev'
- ? [domainName, `chat-${domainName}`]
- : [domainName],
+ aliases,
viewerCertificate: {
cloudfrontDefaultCertificate: false,
acmCertificateArn: certArn,
@@ -390,19 +398,6 @@ if (stack === 'prod') {
},
],
});
-
- new aws.route53.Record('chat', {
- name: 'chat',
- zoneId: zone.zoneId,
- type: 'A',
- aliases: [
- {
- name: cdn.domainName,
- zoneId: cdn.hostedZoneId,
- evaluateTargetHealth: true,
- },
- ],
- });
}
if (stack === 'dev') {
@@ -413,9 +408,11 @@ if (stack === 'dev') {
records: ['macro-site-solidify.pages.dev'],
ttl: 300,
});
+}
- new aws.route53.Record('chat-dev', {
- name: 'chat-dev',
+if (chatSubdomain) {
+ new aws.route53.Record(chatSubdomain, {
+ name: chatSubdomain,
zoneId: zone.zoneId,
type: 'A',
aliases: [