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: process is not defined in worker, so url is defined in a different way

Andras Bacsaicb137e6a49ee
diff --git a/packages/http-client/package.json b/packages/http-client/package.json
index 2d2f75cf01..1336e98bfb 100644
--- a/packages/http-client/package.json
+++ b/packages/http-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@webstudio-is/http-client",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "Webstudio HTTP Client",
"author": "Webstudio <[email protected]>",
"homepage": "https://webstudio.is",
diff --git a/packages/http-client/src/index.ts b/packages/http-client/src/index.ts
index e3a88f3872..51ca682cb6 100644
--- a/packages/http-client/src/index.ts
+++ b/packages/http-client/src/index.ts
@@ -1,18 +1,19 @@
import fetch from "isomorphic-fetch";
import type { Includes, Project } from "./index.d";
-const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
-
export const loadProject = async ({
+ webstudioAPIUrl = null,
projectId,
- host = process.env.DESIGNER_HOST || "localhost:3000",
include = { tree: true, props: true, breakpoints: true },
}: {
+ webstudioAPIUrl: string | null;
projectId: string;
- host?: string;
include?: Includes<boolean>;
}): Promise<Project> => {
- const baseUrl = new URL("/", `${protocol}://${host}`);
+ if (!webstudioAPIUrl) {
+ throw new Error("Webstudio API URL is required.");
+ }
+ const baseUrl = new URL("/", `${webstudioAPIUrl}`);
const treeUrl = new URL(`/rest/tree/${projectId}`, baseUrl);
const propsUrl = new URL(`/rest/props/${projectId}`, baseUrl);
const breakpointsUrl = new URL(`/rest/breakpoints/${projectId}`, baseUrl);