Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/cool-vans-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@bigcommerce/catalyst-makeswift": patch
---

Enable Makeswift builder to work in different environments by adding `apiOrigin` and `appOrigin` props to `ReactRuntimeProvider`.

**Action required:** Add the following environment variables:

- `NEXT_PUBLIC_MAKESWIFT_API_ORIGIN`
- `NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN`

**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.
4 changes: 2 additions & 2 deletions core/app/api/makeswift/[...makeswift]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const defaultVariants: Font['variants'] = [

const handler = MakeswiftApiHandler(process.env.MAKESWIFT_SITE_API_KEY, {
runtime,
apiOrigin: process.env.MAKESWIFT_API_ORIGIN,
appOrigin: process.env.MAKESWIFT_APP_ORIGIN,
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN ?? process.env.MAKESWIFT_API_ORIGIN,
appOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN ?? process.env.MAKESWIFT_APP_ORIGIN,
getFonts() {
return [
{
Expand Down
5 changes: 4 additions & 1 deletion core/lib/content-security-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import builder from 'content-security-policy-builder';

const makeswiftEnabled = !!process.env.MAKESWIFT_SITE_API_KEY;

const makeswiftBaseUrl = process.env.MAKESWIFT_BASE_URL || 'https://app.makeswift.com';
const makeswiftBaseUrl =
process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN ??
process.env.MAKESWIFT_APP_ORIGIN ??
'https://app.makeswift.com';

const frameAncestors = makeswiftEnabled ? makeswiftBaseUrl : 'none';

Expand Down
2 changes: 1 addition & 1 deletion core/lib/makeswift/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ strict(process.env.MAKESWIFT_SITE_API_KEY, 'MAKESWIFT_SITE_API_KEY is required')

export const client = new Makeswift(process.env.MAKESWIFT_SITE_API_KEY, {
runtime,
apiOrigin: process.env.MAKESWIFT_API_ORIGIN,
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN ?? process.env.MAKESWIFT_API_ORIGIN,
});

export const getPageSnapshot = async ({ path, locale }: { path: string; locale: string }) =>
Expand Down
7 changes: 6 additions & 1 deletion core/lib/makeswift/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export function MakeswiftProvider({
siteVersion: SiteVersion | null;
}) {
return (
<ReactRuntimeProvider runtime={runtime} siteVersion={siteVersion}>
<ReactRuntimeProvider
apiOrigin={process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN}
appOrigin={process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN}
runtime={runtime}
siteVersion={siteVersion}
>
<RootStyleRegistry enableCssReset={false}>{children}</RootStyleRegistry>
</ReactRuntimeProvider>
);
Expand Down