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 link preloads (#2940)

Ivan Starkovb1b3174cfaf5
diff --git a/fixtures/webstudio-custom-template/.webstudio/data.json b/fixtures/webstudio-custom-template/.webstudio/data.json
index db611b8fd1..e3703aaf73 100644
--- a/fixtures/webstudio-custom-template/.webstudio/data.json
+++ b/fixtures/webstudio-custom-template/.webstudio/data.json
@@ -1,19 +1,23 @@
{
"build": {
- "id": "0c1fd955-ccd4-45cc-b62d-c12777f2c28b",
+ "id": "8f6d166a-f965-4461-b903-faf265c378f7",
"projectId": "0d856812-61d8-4014-a20a-82e01c0eb8ee",
- "version": 125,
- "createdAt": "2024-02-22T06:28:11.305Z",
- "updatedAt": "2024-02-22T06:28:11.305Z",
+ "version": 127,
+ "createdAt": "2024-02-23T10:10:16.827Z",
+ "updatedAt": "2024-02-23T10:10:16.827Z",
"pages": {
"meta": {
"siteName": "Fixture Site",
"faviconAssetId": "cd1e9fad-8df1-45c6-800f-05fda2d2469f",
"code": "<script>console.log('HELLO')</script>\n<meta property=\"saas:test\" content=\"test\">"
},
- "settings": {
- "atomicStyles": true
- },
+ "redirects": [
+ {
+ "old": "/hello",
+ "new": "/world",
+ "status": "301"
+ }
+ ],
"homePage": {
"id": "nfzls_SkTc9jKYyxcZ8Lw",
"name": "Home",
@@ -42,6 +46,26 @@
},
"rootInstanceId": "LW98_-srDnnagkR10lsk4",
"path": "/script-test"
+ },
+ {
+ "id": "lyz5sZaJ7WzLt71cX3VJ2",
+ "name": "world",
+ "title": "\"Untitled\"",
+ "meta": {
+ "description": "\"\"",
+ "excludePageFromSearch": "false",
+ "socialImageUrl": "\"\"",
+ "status": "200",
+ "redirect": "\"\"",
+ "custom": [
+ {
+ "property": "",
+ "content": "\"\""
+ }
+ ]
+ },
+ "rootInstanceId": "jDb2FuSK2-azIZxkH5XNv",
+ "path": "/world"
}
],
"folders": [
@@ -49,7 +73,11 @@
"id": "root",
"name": "Root",
"slug": "",
- "children": ["nfzls_SkTc9jKYyxcZ8Lw", "xT46WZKzCBTvUCIObMELW"]
+ "children": [
+ "nfzls_SkTc9jKYyxcZ8Lw",
+ "xT46WZKzCBTvUCIObMELW",
+ "lyz5sZaJ7WzLt71cX3VJ2"
+ ]
}
]
},
@@ -585,6 +613,15 @@
}
]
}
+ ],
+ [
+ "jDb2FuSK2-azIZxkH5XNv",
+ {
+ "type": "instance",
+ "id": "jDb2FuSK2-azIZxkH5XNv",
+ "component": "Body",
+ "children": []
+ }
]
],
"deployment": {
@@ -630,6 +667,26 @@
},
"rootInstanceId": "LW98_-srDnnagkR10lsk4",
"path": "/script-test"
+ },
+ {
+ "id": "lyz5sZaJ7WzLt71cX3VJ2",
+ "name": "world",
+ "title": "\"Untitled\"",
+ "meta": {
+ "description": "\"\"",
+ "excludePageFromSearch": "false",
+ "socialImageUrl": "\"\"",
+ "status": "200",
+ "redirect": "\"\"",
+ "custom": [
+ {
+ "property": "",
+ "content": "\"\""
+ }
+ ]
+ },
+ "rootInstanceId": "jDb2FuSK2-azIZxkH5XNv",
+ "path": "/world"
}
],
"assets": [
diff --git a/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx b/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx
index 8752bbaea0..89ecd98fce 100644
--- a/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx
@@ -95,7 +95,7 @@ export const getRemixParams = ({ ...params }: Params): Params => {
return params;
};
-export const pagesPaths = new Set(["", "/script-test"]);
+export const pagesPaths = new Set(["", "/script-test", "/world"]);
export const formsProperties = new Map<
string,
diff --git a/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].ts
index 2a308ddd2d..6a662e0c64 100644
--- a/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].ts
+++ b/fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml].ts
@@ -2,11 +2,15 @@ export const sitemap = {
pages: [
{
path: "",
- lastModified: "2024-02-22T06:28:11.305Z",
+ lastModified: "2024-02-23T10:10:16.827Z",
},
{
path: "/script-test",
- lastModified: "2024-02-22T06:28:11.305Z",
+ lastModified: "2024-02-23T10:10:16.827Z",
+ },
+ {
+ path: "/world",
+ lastModified: "2024-02-23T10:10:16.827Z",
},
],
};
diff --git a/fixtures/webstudio-custom-template/app/__generated__/[world]._index.server.tsx b/fixtures/webstudio-custom-template/app/__generated__/[world]._index.server.tsx
new file mode 100644
index 0000000000..05e605bec5
--- /dev/null
+++ b/fixtures/webstudio-custom-template/app/__generated__/[world]._index.server.tsx
@@ -0,0 +1,4 @@
+type Params = Record<string, string | undefined>;
+export const loadResources = async (_props: { params: Params }) => {
+ return {} as Record<string, unknown>;
+};
diff --git a/fixtures/webstudio-custom-template/app/__generated__/[world]._index.tsx b/fixtures/webstudio-custom-template/app/__generated__/[world]._index.tsx
new file mode 100644
index 0000000000..59c9d877d4
--- /dev/null
+++ b/fixtures/webstudio-custom-template/app/__generated__/[world]._index.tsx
@@ -0,0 +1,82 @@
+/* eslint-disable */
+/* This is a auto generated file for building the project */
+
+import { Fragment, useState } from "react";
+import type {
+ Asset,
+ FontAsset,
+ ImageAsset,
+ ProjectMeta,
+} from "@webstudio-is/sdk";
+import { useResource } from "@webstudio-is/react-sdk";
+import type { PageMeta } from "@webstudio-is/react-sdk";
+import { Body as Body } from "@webstudio-is/sdk-components-react-remix";
+
+import type { PageData } from "~/routes/_index";
+export const imageAssets: ImageAsset[] = [
+ {
+ id: "cd1e9fad-8df1-45c6-800f-05fda2d2469f",
+ name: "home_wsKvRSqvkajPPBeycZ-C8.svg",
+ description: null,
+ projectId: "0d856812-61d8-4014-a20a-82e01c0eb8ee",
+ size: 3350,
+ type: "image",
+ format: "svg",
+ createdAt: "2023-10-30T20:35:47.113Z",
+ meta: { width: 16, height: 16 },
+ },
+];
+
+// Font assets on current page (can be preloaded)
+export const pageFontAssets: FontAsset[] = [];
+
+export const pageBackgroundImageAssets: ImageAsset[] = [];
+
+export const pageData: PageData = {
+ project: {
+ siteName: "Fixture Site",
+ faviconAssetId: "cd1e9fad-8df1-45c6-800f-05fda2d2469f",
+ code: '<script>console.log(\'HELLO\')</script>\n<meta property="saas:test" content="test">',
+ },
+};
+export const user: { email: string | null } | undefined = {
+ email: "[email protected]",
+};
+export const projectId = "0d856812-61d8-4014-a20a-82e01c0eb8ee";
+
+export const getPageMeta = ({
+ params,
+ resources,
+}: {
+ params: Record<string, undefined | string>;
+ resources: Record<string, any>;
+}): PageMeta => {
+ return {
+ title: "Untitled",
+ description: "",
+ excludePageFromSearch: false,
+ socialImageAssetId: undefined,
+ socialImageUrl: "",
+ status: 200,
+ redirect: "",
+ custom: [],
+ };
+};
+
+const Page = ({}: { params: any }) => {
+ return <Body data-ws-id="jDb2FuSK2-azIZxkH5XNv" data-ws-component="Body" />;
+};
+
+export { Page };
+
+type Params = Record<string, string | undefined>;
+export const getRemixParams = ({ ...params }: Params): Params => {
+ return params;
+};
+
+export const pagesPaths = new Set(["", "/script-test", "/world"]);
+
+export const formsProperties = new Map<
+ string,
+ { method?: string; action?: string }
+>([]);
diff --git a/fixtures/webstudio-custom-template/app/__generated__/_index.tsx b/fixtures/webstudio-custom-template/app/__generated__/_index.tsx
index 965e2bd7f7..0da3516c96 100644
--- a/fixtures/webstudio-custom-template/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-custom-template/app/__generated__/_index.tsx
@@ -123,7 +123,7 @@ export const getRemixParams = ({ ...params }: Params): Params => {
return params;
};
-export const pagesPaths = new Set(["", "/script-test"]);
+export const pagesPaths = new Set(["", "/script-test", "/world"]);
export const formsProperties = new Map<
string,
diff --git a/fixtures/webstudio-custom-template/app/routes/[hello]._index.ts b/fixtures/webstudio-custom-template/app/routes/[hello]._index.ts
new file mode 100644
index 0000000000..ed9261af6d
--- /dev/null
+++ b/fixtures/webstudio-custom-template/app/routes/[hello]._index.ts
@@ -0,0 +1,5 @@
+import { type LoaderArgs, redirect } from "@remix-run/server-runtime";
+
+export const loader = (arg: LoaderArgs) => {
+ return redirect("/world", 301);
+};
diff --git a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
index 588ab41812..1a8b01c000 100644
--- a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
new file mode 100644
index 0000000000..1575d5d1d9
--- /dev/null
+++ b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
@@ -0,0 +1,331 @@
+/* eslint-disable camelcase */
+import {
+ type V2_ServerRuntimeMetaFunction,
+ type LinksFunction,
+ type LinkDescriptor,
+ type ActionArgs,
+ type LoaderArgs,
+ json,
+ redirect,
+} from "@remix-run/server-runtime";
+import { useLoaderData } from "@remix-run/react";
+import type { ProjectMeta } from "@webstudio-is/sdk";
+import { ReactSdkContext } from "@webstudio-is/react-sdk";
+import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
+import {
+ pageData,
+ user,
+ projectId,
+ pagesPaths,
+ formsProperties,
+ Page,
+ imageAssets,
+ getRemixParams,
+ getPageMeta,
+ pageFontAssets,
+ pageBackgroundImageAssets,
+} from "../__generated__/[world]._index";
+import { loadResources } from "../__generated__/[world]._index.server";
+import css from "../__generated__/index.css";
+import { assetBaseUrl, imageBaseUrl, imageLoader } from "~/constants.mjs";
+
+export type PageData = {
+ project?: ProjectMeta;
+};
+
+export const loader = async (arg: LoaderArgs) => {
+ const params = getRemixParams(arg.params);
+ const resources = await loadResources({ params });
+ const pageMeta = getPageMeta({ params, resources });
+
+ if (pageMeta.redirect) {
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
+ }
+
+ const host =
+ arg.request.headers.get("x-forwarded-host") ||
+ arg.request.headers.get("host") ||
+ "";
+
+ const url = new URL(arg.request.url);
+ url.host = host;
+ url.protocol = "https";
+
+ // typecheck
+ arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;
+
+ return json(
+ {
+ host,
+ url: url.href,
+ excludeFromSearch: arg.context.EXCLUDE_FROM_SEARCH,
+ params,
+ resources,
+ pageMeta,
+ },
+ // No way for current information to change, so add cache for 10 minutes
+ // In case of CRM Data, this should be set to 0
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
+ );
+};
+
+export const headers = () => {
+ return {
+ "Cache-Control": "public, max-age=0, must-revalidate",
+ };
+};
+
+export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
+ const metas: ReturnType<V2_ServerRuntimeMetaFunction> = [];
+ if (data === undefined) {
+ return metas;
+ }
+ const { pageMeta } = data;
+ const { project } = pageData;
+
+ if (data.url) {
+ metas.push({
+ property: "og:url",
+ content: data.url,
+ });
+ }
+
+ if (pageMeta.title) {
+ metas.push({ title: pageMeta.title });
+
+ metas.push({
+ property: "og:title",
+ content: pageMeta.title,
+ });
+ }
+
+ metas.push({ property: "og:type", content: "website" });
+
+ const origin = `https://${data.host}`;
+
+ if (project?.siteName) {
+ metas.push({
+ property: "og:site_name",
+ content: project.siteName,
+ });
+ metas.push({
+ "script:ld+json": {
+ "@context": "https://schema.org",
+ "@type": "WebSite",
+ name: project.siteName,
+ url: origin,
+ },
+ });
+ }
+
+ if (pageMeta.excludePageFromSearch || data.excludeFromSearch) {
+ metas.push({
+ name: "robots",
+ content: "noindex, nofollow",
+ });
+ }
+
+ if (pageMeta.description) {
+ metas.push({
+ name: "description",
+ content: pageMeta.description,
+ });
+ metas.push({
+ property: "og:description",
+ content: pageMeta.description,
+ });
+ }
+
+ if (pageMeta.socialImageAssetId) {
+ const imageAsset = imageAssets.find(
+ (asset) => asset.id === pageMeta.socialImageAssetId
+ );
+
+ if (imageAsset) {
+ metas.push({
+ property: "og:image",
+ content: `https://${data.host}${imageLoader({
+ src: imageAsset.name,
+ // Do not transform social image (not enough information do we need to do this)
+ format: "raw",
+ })}`,
+ });
+ }
+ } else if (pageMeta.socialImageUrl) {
+ metas.push({
+ property: "og:image",
+ content: pageMeta.socialImageUrl,
+ });
+ }
+
+ metas.push(...pageMeta.custom);
+
+ return metas;
+};
+
+export const links: LinksFunction = () => {
+ const result: LinkDescriptor[] = [];
+
+ result.push({
+ rel: "stylesheet",
+ href: css,
+ });
+
+ const { project } = pageData;
+
+ if (project?.faviconAssetId) {
+ const imageAsset = imageAssets.find(
+ (asset) => asset.id === project.faviconAssetId
+ );
+
+ if (imageAsset) {
+ result.push({
+ rel: "icon",
+ href: imageLoader({
+ src: imageAsset.name,
+ width: 128,
+ quality: 100,
+ format: "auto",
+ }),
+ type: undefined,
+ });
+ }
+ } else {
+ result.push({
+ rel: "icon",
+ href: "/favicon.ico",
+ type: "image/x-icon",
+ });
+
+ result.push({
+ rel: "shortcut icon",
+ href: "/favicon.ico",
+ type: "image/x-icon",
+ });
+ }
+
+ for (const asset of pageFontAssets) {
+ result.push({
+ rel: "preload",
+ href: `${assetBaseUrl}${asset.name}`,
+ as: "font",
+ crossOrigin: "anonymous",
+ });
+ }
+
+ for (const backgroundImageAsset of pageBackgroundImageAssets) {
+ result.push({
+ rel: "preload",
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
+ as: "image",
+ });
+ }
+
+ return result;
+};
+
+const getRequestHost = (request: Request): string =>
+ request.headers.get("x-forwarded-host") || request.headers.get("host") || "";
+
+const getMethod = (value: string | undefined) => {
+ if (value === undefined) {
+ return "post";
+ }
+
+ switch (value.toLowerCase()) {
+ case "get":
+ return "get";
+ default:
+ return "post";
+ }
+};
+
+export const action = async ({ request, context }: ActionArgs) => {
+ const formData = await request.formData();
+
+ const formId = getFormId(formData);
+ if (formId === undefined) {
+ // We're throwing rather than returning { success: false }
+ // because this isn't supposed to happen normally: bug or malicious user
+ throw json("Form not found", { status: 404 });
+ }
+
+ const formProperties = formsProperties.get(formId);
+
+ // form properties are not defined when defaults are used
+ const { action, method } = formProperties ?? {};
+
+ const email = user?.email;
+
+ if (email == null) {
+ return { success: false };
+ }
+
+ // wrapped in try/catch just in cases new URL() throws
+ // (should not happen)
+ let pageUrl: URL;
+ try {
+ pageUrl = new URL(request.url);
+ pageUrl.host = getRequestHost(request);
+ } catch {
+ return { success: false };
+ }
+
+ if (action !== undefined) {
+ try {
+ // Test that action is full URL
+ new URL(action);
+ } catch {
+ return json(
+ {
+ success: false,
+ error: "Invalid action URL, must be valid http/https protocol",
+ },
+ { status: 200 }
+ );
+ }
+ }
+
+ const formInfo = {
+ formData,
+ projectId,
+ action: action ?? null,
+ method: getMethod(method),
+ pageUrl: pageUrl.toString(),
+ toEmail: email,
+ fromEmail: pageUrl.hostname + "@webstudio.email",
+ } as const;
+
+ const result = await n8nHandler({
+ formInfo,
+ hookUrl: context.N8N_FORM_EMAIL_HOOK,
+ });
+
+ return result;
+};
+
+const Outlet = () => {
+ const { params, resources } = useLoaderData<typeof loader>();
+ return (
+ <ReactSdkContext.Provider
+ value={{
+ imageLoader,
+ assetBaseUrl,
+ imageBaseUrl,
+ pagesPaths,
+ resources,
+ }}
+ >
+ <Page params={params} />
+ </ReactSdkContext.Provider>
+ );
+};
+
+export default Outlet;
diff --git a/fixtures/webstudio-custom-template/app/routes/_index.tsx b/fixtures/webstudio-custom-template/app/routes/_index.tsx
index 705dbbe5ff..39dfe4e4e6 100644
--- a/fixtures/webstudio-custom-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/_index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
index 705dbbe5ff..39dfe4e4e6 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
index 705dbbe5ff..39dfe4e4e6 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
index 8f6ef7af2e..5cd09060c8 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
index 627a1e2b5d..9bfbdfa87f 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
index 6db7a9440d..5c534e1838 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
index 6d560615f1..12a73c9015 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
index a1b082a120..9dd572fe4f 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
index dea3a0ccc0..b6cc3640f6 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
index 705dbbe5ff..39dfe4e4e6 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}
diff --git a/packages/cli/templates/defaults/__templates__/route-template.tsx b/packages/cli/templates/defaults/__templates__/route-template.tsx
index 304f35b33e..2b04be8c6e 100644
--- a/packages/cli/templates/defaults/__templates__/route-template.tsx
+++ b/packages/cli/templates/defaults/__templates__/route-template.tsx
@@ -214,18 +214,16 @@ export const links: LinksFunction = () => {
for (const asset of pageFontAssets) {
result.push({
rel: "preload",
- href: assetBaseUrl + asset.name,
+ href: `${assetBaseUrl}${asset.name}`,
as: "font",
+ crossOrigin: "anonymous",
});
}
for (const backgroundImageAsset of pageBackgroundImageAssets) {
result.push({
rel: "preload",
- href: imageLoader({
- src: backgroundImageAsset.name,
- format: "raw",
- }),
+ href: `${assetBaseUrl}${backgroundImageAsset.name}`,
as: "image",
});
}