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.

add env everywhere

Sara Vieira37b4349f97ad
diff --git a/app/routes/canvas.tsx b/app/routes/canvas.tsx
index c7766c33a2..e506e9d440 100644
--- a/app/routes/canvas.tsx
+++ b/app/routes/canvas.tsx
@@ -1,5 +1,10 @@
-import { type MetaFunction } from "@remix-run/node";
+import { LoaderFunction, type MetaFunction } from "@remix-run/node";
import { Canvas } from "~/shared/documents/canvas";
+import env from "~/env.server";
+
+export const loader: LoaderFunction = () => ({
+ env,
+});
export const meta: MetaFunction = () => {
return { title: "Webstudio canvas" };
diff --git a/app/routes/canvas/$projectId.tsx b/app/routes/canvas/$projectId.tsx
index 2d5c7d9a06..864b48702d 100644
--- a/app/routes/canvas/$projectId.tsx
+++ b/app/routes/canvas/$projectId.tsx
@@ -2,12 +2,13 @@ import { useLoaderData } from "@remix-run/react";
import type { LoaderFunction } from "@remix-run/node";
import { Canvas } from "~/canvas";
import { loadCanvasData, type ErrorData, type CanvasData } from "~/shared/db";
+import env from "~/env.server";
export const loader: LoaderFunction = async ({
params,
}): Promise<CanvasData | ErrorData> => {
if (params.projectId === undefined) {
- return { errors: "Missing projectId" };
+ return { errors: "Missing projectId", env };
}
try {
return await loadCanvasData({ projectId: params.projectId });
@@ -15,10 +16,11 @@ export const loader: LoaderFunction = async ({
if (error instanceof Error) {
return {
errors: error.message,
+ env,
};
}
}
- return { errors: "Unexpected error" };
+ return { errors: "Unexpected error", env };
};
const CanvasRoute = () => {
diff --git a/app/routes/designer.tsx b/app/routes/designer.tsx
index 103455462f..932f3a8cac 100644
--- a/app/routes/designer.tsx
+++ b/app/routes/designer.tsx
@@ -1,5 +1,10 @@
-import type { MetaFunction } from "@remix-run/node";
+import type { LoaderFunction, MetaFunction } from "@remix-run/node";
import { Designer } from "~/shared/documents/designer";
+import env from "~/env.server";
+
+export const loader: LoaderFunction = () => ({
+ env,
+});
export const meta: MetaFunction = () => {
return { title: "Webstudio" };
diff --git a/app/routes/index.tsx b/app/routes/index.tsx
index 3aa668bf61..26211f87dd 100644
--- a/app/routes/index.tsx
+++ b/app/routes/index.tsx
@@ -4,14 +4,18 @@ import { Root, type Data } from "@webstudio-is/sdk";
import config from "~/config";
import * as db from "~/shared/db";
import Document from "./canvas";
+import env, { Env } from "~/env.server";
// @todo all this subdomain logic is very hacky
type Error = { errors: string };
+type LoaderReturnProps = Promise<
+ (Data & { env: Env }) | (Error & { env: Env }) | Response
+>;
export const loader: LoaderFunction = async ({
request,
-}): Promise<Data | Error | Response> => {
+}): LoaderReturnProps => {
const host =
request.headers.get("x-forwarded-host") ||
request.headers.get("host") ||
@@ -42,10 +46,10 @@ export const loader: LoaderFunction = async ({
if (breakpoints === null) {
throw new Error(`Breakpoints for tree ${project.prodTreeId} not found`);
}
- return { tree, props, breakpoints: breakpoints.values };
+ return { tree, props, breakpoints: breakpoints.values, env };
} catch (error) {
if (error instanceof Error) {
- return { errors: error.message };
+ return { errors: error.message, env };
}
}
}
diff --git a/app/routes/login.tsx b/app/routes/login.tsx
index 9371c4133e..2c24216657 100644
--- a/app/routes/login.tsx
+++ b/app/routes/login.tsx
@@ -1,5 +1,10 @@
-import { MetaFunction } from "@remix-run/node";
+import { LoaderFunction, MetaFunction } from "@remix-run/node";
import { Designer } from "~/shared/documents/designer";
+import env from "~/env.server";
+
+export const loader: LoaderFunction = () => ({
+ env,
+});
export const meta: MetaFunction = () => {
return { title: "Webstudio Login" };
diff --git a/app/routes/preview.tsx b/app/routes/preview.tsx
index d43bf891b4..9c73c174e5 100644
--- a/app/routes/preview.tsx
+++ b/app/routes/preview.tsx
@@ -1,5 +1,10 @@
-import { type MetaFunction } from "@remix-run/node";
+import { LoaderFunction, type MetaFunction } from "@remix-run/node";
import { Canvas } from "~/shared/documents/canvas";
+import env from "~/env.server";
+
+export const loader: LoaderFunction = () => ({
+ env,
+});
export const meta: MetaFunction = () => {
return { title: "Webstudio site preview" };