Skip to content

Commit c496e8a

Browse files
committed
Fix issues with S3/CDN and fix actions list state
1 parent 2191c1d commit c496e8a

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

apps/nextjs/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const nextConfig = {
3737
search: "",
3838
},
3939
{
40+
// local
4041
protocol: "https",
4142
hostname: "d3t9degcpc8bgc.cloudfront.net",
4243
},

infra/nextjs.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ const NEXT_PUBLIC_BASE_URL =
6060
? "https://d1a1w7ulyz8ubg.cloudfront.net"
6161
: "http://localhost:3000";
6262

63+
const NEXT_PUBLIC_CDN_DOMAIN =
64+
$app.stage === "production"
65+
? "https://cdn.joinhomefront.org"
66+
: $app.stage === "staging"
67+
? "https://staging-cdn.joinhomefront.org"
68+
: $app.stage === "development"
69+
? "https://d3t9degcpc8bgc.cloudfront.net"
70+
: "https://d3t9degcpc8bgc.cloudfront.net";
71+
6372
function getDomain(): NextjsArgs["domain"] | undefined {
6473
switch ($app.stage) {
6574
// case "development":
@@ -124,6 +133,7 @@ export const nextjs = new sst.aws.Nextjs("Web", {
124133
],
125134
environment: {
126135
NEXT_PUBLIC_BASE_URL,
136+
NEXT_PUBLIC_CDN_DOMAIN,
127137
NEXT_PUBLIC_PROTOMAPS_API_KEY,
128138
NEXT_PUBLIC_STRIPE_BILLING_RETURN_URL,
129139
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,
@@ -145,7 +155,6 @@ export const nextjs = new sst.aws.Nextjs("Web", {
145155
STRIPE_HASH_KEY: stripeHashKey.value,
146156
STRIPE_SECRET_KEY: stripeSecretKey.value,
147157
STRIPE_WEBHOOK_SECRET: stripeWebhookSecret.value,
148-
NEXT_PUBLIC_CDN_DOMAIN: "https://d3t9degcpc8bgc.cloudfront.net",
149158
},
150159
vpc,
151160
});

infra/storage.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ export const bucket = new sst.aws.Bucket("homefront-next-prod", {
66

77
export const cdnBucket = new sst.aws.Bucket("join-homefront", {
88
access: "public",
9-
transform: {
10-
bucket(args, opts) {
11-
args.bucket = $app.stage === "production" ? "join-homefront" : undefined;
12-
opts.import = $app.stage === "production" ? "join-homefront" : undefined;
13-
},
14-
},
159
});
1610

1711
export const cdn = new sst.aws.Cdn("CDN", {
@@ -21,6 +15,18 @@ export const cdn = new sst.aws.Cdn("CDN", {
2115
domainName: cdnBucket.domain,
2216
},
2317
],
18+
domain:
19+
$app.stage === "production"
20+
? {
21+
name: "cdn.joinhomefront.org",
22+
dns: sst.cloudflare.dns(),
23+
}
24+
: $app.stage === "staging"
25+
? {
26+
name: "staging-cdn.joinhomefront.org",
27+
dns: sst.cloudflare.dns(),
28+
}
29+
: undefined,
2430
defaultCacheBehavior: {
2531
targetOriginId: cdnBucket.arn,
2632
allowedMethods: ["GET", "HEAD", "OPTIONS"],

packages/app/features/actions/RecommendedActionsList.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ export function RecommendedActionsList() {
3636
}
3737
}, [isLoading, recommendedActions, hasAttemptedGeneration]);
3838

39-
if (
40-
isLoading ||
41-
generateRecommendedActions.isPending ||
42-
!recommendedActions?.length
43-
) {
39+
if (isLoading || generateRecommendedActions.isPending) {
4440
return (
4541
<View className="flex-1 items-center justify-center p-4">
4642
<ActivityIndicator />
@@ -57,7 +53,7 @@ export function RecommendedActionsList() {
5753
)}
5854
ListEmptyComponent={() => (
5955
<Text className="py-4 text-left text-gray-500">
60-
You don't have any recommended actions yet.
56+
You don't have any recommended actions right now.
6157
</Text>
6258
)}
6359
keyExtractor={(recommendedAction) =>

packages/aws/src/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@ import { Resource } from "sst";
33

44
const BUCKET_NAME = Resource["join-homefront"].name;
55

6-
const opts =
7-
Resource.App.stage === "production"
8-
? {
9-
region: "us-east-2",
10-
endpoint: `https://${BUCKET_NAME}.s3.us-east-2.amazonaws.com`,
11-
}
12-
: {};
13-
14-
const s3 = new S3Client(opts);
6+
const s3 = new S3Client({});
157

168
const MIME_TO_EXT = {
179
"image/jpeg": ".jpg",

0 commit comments

Comments
 (0)