-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathsst.config.ts
More file actions
42 lines (40 loc) · 1.68 KB
/
Copy pathsst.config.ts
File metadata and controls
42 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
export default $config({
app(input) {
return {
name: 'relay-web',
home: 'aws',
removal: input?.stage === 'production' ? 'retain' : 'remove',
};
},
run() {
const isProd = $app.stage === 'production';
const domain = isProd ? 'orgin.agentrelay.net' : `${$app.stage}.agentrelay.net`;
const NEXT_PUBLIC_POSTHOG_HOST = process.env.NEXT_PUBLIC_POSTHOG_HOST ?? 'https://i.agentrelay.com';
const NEXT_PUBLIC_POSTHOG_KEY = process.env.NEXT_PUBLIC_POSTHOG_KEY ?? '';
// Non-prod stages reuse a shared CloudFront cache policy + KV store so the
// per-account quotas (20 cache policies / 5 KV stores) don't cap how many
// preview deploys can exist concurrently. The IDs are written to SSM by
// web/scripts/bootstrap-preview-infra.sh; SST namespaces KV keys by stage
// so a shared store is safe.
const previewCachePolicyId = isProd
? undefined
: aws.ssm.getParameterOutput({ name: '/relay-web/preview/cache-policy-id' }).value;
const previewKvStoreArn = isProd
? undefined
: aws.ssm.getParameterOutput({ name: '/relay-web/preview/kv-store-arn' }).value;
new sst.aws.Nextjs('Web', {
path: '.',
openNextVersion: '3.9.16',
environment: {
NEXT_PUBLIC_POSTHOG_HOST,
NEXT_PUBLIC_POSTHOG_KEY,
},
// Production deploys land on orgin.agentrelay.net; SEO canonicals are set in Next metadata.
domain: { name: domain, dns: sst.cloudflare.dns({ proxy: true }) },
...(previewCachePolicyId ? { cachePolicy: previewCachePolicyId } : {}),
...(previewKvStoreArn
? { edge: { viewerRequest: { kvStore: previewKvStoreArn, injection: '' } } }
: {}),
});
},
});