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: og-image bug fix for local assets (#5184)

Jaya Krishna Namburube6b5fa96605
diff --git a/fixtures/react-router-cloudflare/app/routes/[another-page]._index.tsx b/fixtures/react-router-cloudflare/app/routes/[another-page]._index.tsx
index 11b08fc442..a1ab01857d 100644
--- a/fixtures/react-router-cloudflare/app/routes/[another-page]._index.tsx
+++ b/fixtures/react-router-cloudflare/app/routes/[another-page]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-cloudflare/app/routes/_index.tsx b/fixtures/react-router-cloudflare/app/routes/_index.tsx
index c909d7735d..c9dc7e83ff 100644
--- a/fixtures/react-router-cloudflare/app/routes/_index.tsx
+++ b/fixtures/react-router-cloudflare/app/routes/_index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-docker/app/routes/[another-page]._index.tsx b/fixtures/react-router-docker/app/routes/[another-page]._index.tsx
index 11b08fc442..a1ab01857d 100644
--- a/fixtures/react-router-docker/app/routes/[another-page]._index.tsx
+++ b/fixtures/react-router-docker/app/routes/[another-page]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-docker/app/routes/_index.tsx b/fixtures/react-router-docker/app/routes/_index.tsx
index c909d7735d..c9dc7e83ff 100644
--- a/fixtures/react-router-docker/app/routes/_index.tsx
+++ b/fixtures/react-router-docker/app/routes/_index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx b/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx
index 11b08fc442..a1ab01857d 100644
--- a/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx
+++ b/fixtures/react-router-netlify/app/routes/[another-page]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-netlify/app/routes/_index.tsx b/fixtures/react-router-netlify/app/routes/_index.tsx
index c909d7735d..c9dc7e83ff 100644
--- a/fixtures/react-router-netlify/app/routes/_index.tsx
+++ b/fixtures/react-router-netlify/app/routes/_index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx b/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx
index 11b08fc442..a1ab01857d 100644
--- a/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx
+++ b/fixtures/react-router-vercel/app/routes/[another-page]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/react-router-vercel/app/routes/_index.tsx b/fixtures/react-router-vercel/app/routes/_index.tsx
index c909d7735d..c9dc7e83ff 100644
--- a/fixtures/react-router-vercel/app/routes/_index.tsx
+++ b/fixtures/react-router-vercel/app/routes/_index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/ssg-netlify-by-project-id/pages/index/+Head.tsx b/fixtures/ssg-netlify-by-project-id/pages/index/+Head.tsx
index 4357741b6b..4ce7e26b93 100644
--- a/fixtures/ssg-netlify-by-project-id/pages/index/+Head.tsx
+++ b/fixtures/ssg-netlify-by-project-id/pages/index/+Head.tsx
@@ -20,7 +20,7 @@ export const Head = ({ data }: { data: PageContext["data"] }) => {
let socialImageUrl = pageMeta.socialImageUrl;
if (pageMeta.socialImageAssetName) {
socialImageUrl = `${origin}${imageLoader({
- src: pageMeta.socialImageAssetName,
+ src: `${assetBaseUrl}/${pageMeta.socialImageAssetName}`,
// Do not transform social image (not enough information do we need to do this)
format: "raw",
})}`;
diff --git a/fixtures/ssg/pages/another-page/+Head.tsx b/fixtures/ssg/pages/another-page/+Head.tsx
index 3f18b4cd0a..babaa77f81 100644
--- a/fixtures/ssg/pages/another-page/+Head.tsx
+++ b/fixtures/ssg/pages/another-page/+Head.tsx
@@ -20,7 +20,7 @@ export const Head = ({ data }: { data: PageContext["data"] }) => {
let socialImageUrl = pageMeta.socialImageUrl;
if (pageMeta.socialImageAssetName) {
socialImageUrl = `${origin}${imageLoader({
- src: pageMeta.socialImageAssetName,
+ src: `${assetBaseUrl}/${pageMeta.socialImageAssetName}`,
// Do not transform social image (not enough information do we need to do this)
format: "raw",
})}`;
diff --git a/fixtures/ssg/pages/index/+Head.tsx b/fixtures/ssg/pages/index/+Head.tsx
index 4357741b6b..4ce7e26b93 100644
--- a/fixtures/ssg/pages/index/+Head.tsx
+++ b/fixtures/ssg/pages/index/+Head.tsx
@@ -20,7 +20,7 @@ export const Head = ({ data }: { data: PageContext["data"] }) => {
let socialImageUrl = pageMeta.socialImageUrl;
if (pageMeta.socialImageAssetName) {
socialImageUrl = `${origin}${imageLoader({
- src: pageMeta.socialImageAssetName,
+ src: `${assetBaseUrl}/${pageMeta.socialImageAssetName}`,
// Do not transform social image (not enough information do we need to do this)
format: "raw",
})}`;
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
index 2ad19d5dc8..ac077c8564 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
@@ -286,6 +286,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
<PageSettingsCanonicalLink href={url} />
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
index a176476859..f636f7fb56 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
@@ -286,6 +286,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
<PageSettingsCanonicalLink href={url} />
diff --git a/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx
index 3cd7e27088..a7677fa869 100644
--- a/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[_route_with_symbols_]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[animations]._index.tsx b/fixtures/webstudio-features/app/routes/[animations]._index.tsx
index 61c80ec7c5..89415d5ad0 100644
--- a/fixtures/webstudio-features/app/routes/[animations]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[animations]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[class-names]._index.tsx b/fixtures/webstudio-features/app/routes/[class-names]._index.tsx
index b875a9a49a..7200178cc4 100644
--- a/fixtures/webstudio-features/app/routes/[class-names]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[class-names]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[content-block]._index.tsx b/fixtures/webstudio-features/app/routes/[content-block]._index.tsx
index a639e47c27..19b58fb925 100644
--- a/fixtures/webstudio-features/app/routes/[content-block]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[content-block]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[duration]._index.tsx b/fixtures/webstudio-features/app/routes/[duration]._index.tsx
index 9a5176587a..df5f72ffef 100644
--- a/fixtures/webstudio-features/app/routes/[duration]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[duration]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[expressions]._index.tsx b/fixtures/webstudio-features/app/routes/[expressions]._index.tsx
index 764940dcec..9f1b467052 100644
--- a/fixtures/webstudio-features/app/routes/[expressions]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[expressions]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[form]._index.tsx b/fixtures/webstudio-features/app/routes/[form]._index.tsx
index 6c9b6804d0..74b1787cea 100644
--- a/fixtures/webstudio-features/app/routes/[form]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[form]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx b/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx
index 43f32f3b6e..ff56a506a1 100644
--- a/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[head-tag]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx b/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx
index 38e8efe122..4e57e41bbf 100644
--- a/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[heading-with-id]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx b/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx
index 778143e440..d09961d9ea 100644
--- a/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[nested].[nested-page]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[radix]._index.tsx b/fixtures/webstudio-features/app/routes/[radix]._index.tsx
index fa1eb61272..3a3e9764d4 100644
--- a/fixtures/webstudio-features/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[radix]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[resources]._index.tsx b/fixtures/webstudio-features/app/routes/[resources]._index.tsx
index b8cf43aa49..49fbbbaf90 100644
--- a/fixtures/webstudio-features/app/routes/[resources]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[resources]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx b/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx
index 23ff00c3d8..bc4fb303ed 100644
--- a/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx
+++ b/fixtures/webstudio-features/app/routes/[text-duration]._index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/fixtures/webstudio-features/app/routes/_index.tsx b/fixtures/webstudio-features/app/routes/_index.tsx
index c909d7735d..c9dc7e83ff 100644
--- a/fixtures/webstudio-features/app/routes/_index.tsx
+++ b/fixtures/webstudio-features/app/routes/_index.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/packages/cli/templates/defaults/app/route-templates/html.tsx b/packages/cli/templates/defaults/app/route-templates/html.tsx
index 40b5d144ca..55f0e342db 100644
--- a/packages/cli/templates/defaults/app/route-templates/html.tsx
+++ b/packages/cli/templates/defaults/app/route-templates/html.tsx
@@ -286,6 +286,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
<PageSettingsCanonicalLink href={url} />
diff --git a/packages/cli/templates/react-router/app/route-templates/html.tsx b/packages/cli/templates/react-router/app/route-templates/html.tsx
index 624fb38fc6..e31c3fd6aa 100644
--- a/packages/cli/templates/react-router/app/route-templates/html.tsx
+++ b/packages/cli/templates/react-router/app/route-templates/html.tsx
@@ -285,6 +285,7 @@ const Outlet = () => {
host={host}
siteName={siteName}
imageLoader={imageLoader}
+ assetBaseUrl={assetBaseUrl}
/>
<PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
diff --git a/packages/cli/templates/ssg/app/route-templates/html/+Head.tsx b/packages/cli/templates/ssg/app/route-templates/html/+Head.tsx
index 14b16173ec..a987789212 100644
--- a/packages/cli/templates/ssg/app/route-templates/html/+Head.tsx
+++ b/packages/cli/templates/ssg/app/route-templates/html/+Head.tsx
@@ -20,7 +20,7 @@ export const Head = ({ data }: { data: PageContext["data"] }) => {
let socialImageUrl = pageMeta.socialImageUrl;
if (pageMeta.socialImageAssetName) {
socialImageUrl = `${origin}${imageLoader({
- src: pageMeta.socialImageAssetName,
+ src: `${assetBaseUrl}/${pageMeta.socialImageAssetName}`,
// Do not transform social image (not enough information do we need to do this)
format: "raw",
})}`;
diff --git a/packages/react-sdk/src/page-settings-meta.tsx b/packages/react-sdk/src/page-settings-meta.tsx
index a0f179c2c7..9aaa44bf78 100644
--- a/packages/react-sdk/src/page-settings-meta.tsx
+++ b/packages/react-sdk/src/page-settings-meta.tsx
@@ -66,12 +66,14 @@ export const PageSettingsMeta = ({
siteName,
pageMeta,
imageLoader,
+ assetBaseUrl,
}: {
url?: string;
host: string;
siteName: string;
pageMeta: PageMeta;
imageLoader: ImageLoader;
+ assetBaseUrl: string;
}) => {
const metas: // | { title: string }
{ property?: string; name?: string; content: string }[] = [];
@@ -121,7 +123,7 @@ export const PageSettingsMeta = ({
metas.push({
property: "og:image",
content: `https://${host}${imageLoader({
- src: pageMeta.socialImageAssetName,
+ src: `${assetBaseUrl}${pageMeta.socialImageAssetName}`,
// Do not transform social image (not enough information do we need to do this)
format: "raw",
})}`,