Skip to content

Commit ff68bc2

Browse files
authored
Merge pull request #2736 from bigcommerce/fix/staging
fix: include apiOrigin and appOrigin props to Makeswift provider
2 parents 61f7351 + 05f40a2 commit ff68bc2

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

.changeset/cool-vans-pay.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@bigcommerce/catalyst-makeswift": patch
3+
---
4+
5+
Enable Makeswift builder to work in different environments by adding `apiOrigin` and `appOrigin` props to `ReactRuntimeProvider`.
6+
7+
**Action required:** Add the following environment variables:
8+
9+
- `NEXT_PUBLIC_MAKESWIFT_API_ORIGIN`
10+
- `NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN`
11+
12+
**Deprecation notice:** `MAKESWIFT_API_ORIGIN` and `MAKESWIFT_APP_ORIGIN` are deprecated and will be removed in v1.4.0. Prefix `MAKESWIFT_API_ORIGIN` and `MAKESWIFT_APP_ORIGIN` with `NEXT_PUBLIC_` to migrate.

core/app/api/makeswift/[...makeswift]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const defaultVariants: Font['variants'] = [
2424

2525
const handler = MakeswiftApiHandler(process.env.MAKESWIFT_SITE_API_KEY, {
2626
runtime,
27-
apiOrigin: process.env.MAKESWIFT_API_ORIGIN,
28-
appOrigin: process.env.MAKESWIFT_APP_ORIGIN,
27+
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN ?? process.env.MAKESWIFT_API_ORIGIN,
28+
appOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN ?? process.env.MAKESWIFT_APP_ORIGIN,
2929
getFonts() {
3030
return [
3131
{

core/lib/content-security-policy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import builder from 'content-security-policy-builder';
22

33
const makeswiftEnabled = !!process.env.MAKESWIFT_SITE_API_KEY;
44

5-
const makeswiftBaseUrl = process.env.MAKESWIFT_BASE_URL || 'https://app.makeswift.com';
5+
const makeswiftBaseUrl =
6+
process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN ??
7+
process.env.MAKESWIFT_APP_ORIGIN ??
8+
'https://app.makeswift.com';
69

710
const frameAncestors = makeswiftEnabled ? makeswiftBaseUrl : 'none';
811

core/lib/makeswift/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ strict(process.env.MAKESWIFT_SITE_API_KEY, 'MAKESWIFT_SITE_API_KEY is required')
1111

1212
export const client = new Makeswift(process.env.MAKESWIFT_SITE_API_KEY, {
1313
runtime,
14-
apiOrigin: process.env.MAKESWIFT_API_ORIGIN,
14+
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN ?? process.env.MAKESWIFT_API_ORIGIN,
1515
});
1616

1717
export const getPageSnapshot = async ({ path, locale }: { path: string; locale: string }) =>

core/lib/makeswift/provider.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ export function MakeswiftProvider({
1313
siteVersion: SiteVersion | null;
1414
}) {
1515
return (
16-
<ReactRuntimeProvider runtime={runtime} siteVersion={siteVersion}>
16+
<ReactRuntimeProvider
17+
apiOrigin={process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN}
18+
appOrigin={process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN}
19+
runtime={runtime}
20+
siteVersion={siteVersion}
21+
>
1722
<RootStyleRegistry enableCssReset={false}>{children}</RootStyleRegistry>
1823
</ReactRuntimeProvider>
1924
);

0 commit comments

Comments
 (0)