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.

Merge branch 'main' into edge

Andras Bacsai4e415c35ee78
diff --cc apps/designer/app/routes/rest/publish.ts
index d3518b57be,29fa2dd5cf..b2a55e6aab
--- a/apps/designer/app/routes/rest/publish.ts
+++ b/apps/designer/app/routes/rest/publish.ts
@@@ -1,33 -1,17 +1,37 @@@
import { type ActionFunction } from "@remix-run/node";
+ import { zfd } from "zod-form-data";
import * as db from "~/shared/db";
+ const schema = zfd.formData({
+ domain: zfd.text(),
+ projectId: zfd.text(),
+ });
+
export const action: ActionFunction = async ({ request }) => {
- const formData = await request.formData();
- const domain = formData.get("domain") as string | null;
- const projectId = formData.get("projectId") as string | null;
+ const { domain, projectId } = schema.parse(await request.formData());
+ if (!domain || !projectId) {
+ throw new Error("Domain or ProjectId not provided.");
+ }
try {
- const project = await db.misc.publish({ projectId, domain });
- return { domain: project.domain };
+ await db.misc.publish({ projectId, domain });
+ if (process.env.PUBLISHER_ENDPOINT) {
+ const headers = new Headers();
+ headers.append("X-AUTH-WEBSTUDIO", process.env.PUBLISHER_TOKEN || "");
+ headers.append("Content-Type", "text/plain");
+ const response = await fetch(process.env.PUBLISHER_ENDPOINT, {
+ method: "PUT",
+ headers,
+ body: JSON.stringify({
+ projectId,
+ domain,
+ }),
+ });
+ const text = await response.text();
+ if (!response.ok) {
+ throw new Error(text);
+ }
+ }
+ return { domain };
} catch (error) {
if (error instanceof Error) {
return {