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: Fix clone from builder when shared link is used (#2883)

Oleg Isonenf3c815d5248a
diff --git a/apps/builder/app/shared/clone-project.tsx b/apps/builder/app/shared/clone-project.tsx
index afa2086782..a6b845a3f4 100644
--- a/apps/builder/app/shared/clone-project.tsx
+++ b/apps/builder/app/shared/clone-project.tsx
@@ -17,8 +17,11 @@ import {
import { Title, type ProjectRouter, Project } from "@webstudio-is/project";
import { projectsPath, builderPath } from "~/shared/router-utils";
import { createTrpcRemixProxy } from "~/shared/remix/trpc-remix-proxy";
+import { $authToken } from "./nano-states";
-const trpc = createTrpcRemixProxy<ProjectRouter>(projectsPath);
+const trpc = createTrpcRemixProxy<ProjectRouter>((method) =>
+ projectsPath(method, { authToken: $authToken.get() })
+);
const useCloneProject = ({
projectId,
diff --git a/apps/builder/app/shared/router-utils/path-utils.ts b/apps/builder/app/shared/router-utils/path-utils.ts
index 20046a9ace..8b8635c197 100644
--- a/apps/builder/app/shared/router-utils/path-utils.ts
+++ b/apps/builder/app/shared/router-utils/path-utils.ts
@@ -73,7 +73,18 @@ export const builderDomainsPath = (method: string) => {
}`;
};
-export const projectsPath = (method: string) => `/rest/projects/${method}`;
+export const projectsPath = (
+ method: string,
+ { authToken }: { authToken?: string } = {}
+) => {
+ const path = `/rest/projects/${method}`;
+ if (authToken === undefined) {
+ return path;
+ }
+ const urlSearchParams = new URLSearchParams();
+ urlSearchParams.set("authToken", authToken);
+ return path + `?${urlSearchParams.toString()}`;
+};
export const dashboardProjectsPath = (method: string) =>
`${dashboardPath()}/projects/${method}`;