Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: Publisher deployment instead of CF

Andras Bacsaic21413eef073
diff --git a/apps/designer/.env.example b/apps/designer/.env.example
index 3f97c8d3d5..e19597ce62 100644
--- a/apps/designer/.env.example
+++ b/apps/designer/.env.example
@@ -20,10 +20,6 @@ S3_SECRET_ACCESS_KEY=
ASSET_CDN_URL=
# Publish to edge
-EDGE_DEPLOYMENT=
+EDGE_PUBLISHER_ENDPOINT=
EDGE_DOMAIN=
-
-# Cloudflare API
-CF_ACCOUNT_ID=
-CF_NAMESPACE_ID=
-CF_TOKEN=
\ No newline at end of file
+EDGE_TOKEN=
diff --git a/apps/designer/app/designer/features/topbar/publish.tsx b/apps/designer/app/designer/features/topbar/publish.tsx
index de1fd59a0b..5ce1657a9a 100644
--- a/apps/designer/app/designer/features/topbar/publish.tsx
+++ b/apps/designer/app/designer/features/topbar/publish.tsx
@@ -20,7 +20,7 @@ import env from "~/shared/env";
type PublishButtonProps = { project: Project };
const host = () => {
- if (env.EDGE_DEPLOYMENT && env.EDGE_DOMAIN !== "") {
+ if (env.EDGE_PUBLISHER_ENDPOINT && env.EDGE_DOMAIN !== "") {
return env.EDGE_DOMAIN;
}
if (typeof location === "object") {
diff --git a/apps/designer/app/env.server.ts b/apps/designer/app/env.server.ts
index d0a64b54ff..c23608fa8d 100644
--- a/apps/designer/app/env.server.ts
+++ b/apps/designer/app/env.server.ts
@@ -5,7 +5,7 @@ const env = {
VERCEL_ENV: process.env.VERCEL_ENV,
DEBUG: process.env.DEBUG,
FEATURES: process.env.FEATURES,
- EDGE_DEPLOYMENT: process.env.EDGE_DEPLOYMENT === "true",
+ EDGE_PUBLISHER_ENDPOINT: process.env.EDGE_PUBLISHER_ENDPOINT,
EDGE_DOMAIN: process.env.EDGE_DOMAIN,
} as const;
diff --git a/apps/designer/app/routes/rest/publish.ts b/apps/designer/app/routes/rest/publish.ts
index 79b5e83675..6e808853bb 100644
--- a/apps/designer/app/routes/rest/publish.ts
+++ b/apps/designer/app/routes/rest/publish.ts
@@ -9,42 +9,25 @@ export const action: ActionFunction = async ({ request }) => {
throw new Error("Domain or ProjectId not provided.");
}
try {
- const project = await db.misc.publish({ projectId, domain });
- const projectLoad = await db.project.loadById(projectId);
- const tree = await db.tree.loadByProject(projectLoad);
- if (!tree) {
- throw new Error("No tree found!");
- }
- const breakpoints = await db.breakpoints.getBreakpointsWithId();
- const props = await db.props.loadByTreeId(tree.id);
-
- if (process.env.EDGE_DEPLOYMENT) {
+ await db.misc.publish({ projectId, domain });
+ if (process.env.EDGE_PUBLISHER_ENDPOINT) {
const headers = new Headers();
- headers.append("Authorization", `Bearer ${process.env.CF_TOKEN || ""}`);
+ headers.append("X-AUTH-WEBSTUDIO", process.env.EDGE_TOKEN || "");
headers.append("Content-Type", "text/plain");
- const response = await fetch(
- `https://api.cloudflare.com/client/v4/accounts/${
- process.env.CF_ACCOUNT_ID
- }/storage/kv/namespaces/${
- process.env.CF_NAMESPACE_ID
- }/values/${domain.toLowerCase()}`,
- {
- method: "PUT",
- headers,
- body: JSON.stringify({
- updated: new Date().getTime(),
- tree,
- breakpoints,
- props,
- }),
- }
- );
+ const response = await fetch(process.env.EDGE_PUBLISHER_ENDPOINT, {
+ method: "PUT",
+ headers,
+ body: JSON.stringify({
+ projectId,
+ domain,
+ }),
+ });
const text = await response.text();
if (!response.ok) {
throw new Error(text);
}
}
- return { domain: project.domain };
+ return { domain };
} catch (error) {
if (error instanceof Error) {
return {