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.

rename isCanvasRequest

Roman Pominovc06796fdf112
diff --git a/apps/designer/app/entry.server.tsx b/apps/designer/app/entry.server.tsx
index 969eed6c8e..bb0a1594a9 100644
--- a/apps/designer/app/entry.server.tsx
+++ b/apps/designer/app/entry.server.tsx
@@ -4,7 +4,7 @@ import { initSentry } from "./shared/sentry";
import { prisma } from "@webstudio-is/prisma-client";
import { handleRequest as handleRequestDesigner } from "./shared/remix";
import { handleRequest as handleRequestCanvas } from "@webstudio-is/react-sdk";
-import { isCanvasRequest } from "./routes/$";
+import { getCanvasRequestParams } from "./routes/$";
initSentry({
integrations: [new Sentry.Integrations.Prisma({ client: prisma })],
@@ -18,7 +18,7 @@ export default function handleRequest(
) {
let handle = handleRequestDesigner;
- if (isCanvasRequest(request)) {
+ if (getCanvasRequestParams(request) !== undefined) {
handle = handleRequestCanvas;
}
diff --git a/apps/designer/app/routes/$.tsx b/apps/designer/app/routes/$.tsx
index 522d4ee880..50b130a72e 100644
--- a/apps/designer/app/routes/$.tsx
+++ b/apps/designer/app/routes/$.tsx
@@ -17,15 +17,17 @@ type Data =
type ProjectIdentifier = { type: "id" | "domain"; value: string };
-export const isCanvasRequest = (
+export const getCanvasRequestParams = (
request: Request
-): false | { projectId: ProjectIdentifier; mode: Mode; pathname: string } => {
+):
+ | { projectId: ProjectIdentifier; mode: Mode; pathname: string }
+ | undefined => {
const url = new URL(request.url);
const pathname = url.pathname;
if (Object.values(config).some((path) => pathname.startsWith(path))) {
- return false;
+ return undefined;
}
let projectId: ProjectIdentifier | undefined = undefined;
@@ -48,7 +50,7 @@ export const isCanvasRequest = (
}
if (projectId === undefined) {
- return false;
+ return undefined;
}
const modeParam = url.searchParams.get("mode");
@@ -76,9 +78,9 @@ export const loader: LoaderFunction = async ({
request,
}): Promise<Data | Response> => {
try {
- const canvasRequest = isCanvasRequest(request);
+ const canvasRequest = getCanvasRequestParams(request);
- if (canvasRequest === false) {
+ if (canvasRequest === undefined) {
return redirect(config.dashboardPath);
}