Skip to content

fix(ssg): fix og:url leaking Docker internal URL and make og:image absolute#19

Merged
vianmora merged 3 commits into
mainfrom
fix/ssg-og-meta-internal-url
Jun 12, 2026
Merged

fix(ssg): fix og:url leaking Docker internal URL and make og:image absolute#19
vianmora merged 3 commits into
mainfrom
fix/ssg-og-meta-internal-url

Conversation

@vianmora

Copy link
Copy Markdown
Contributor

Problem

In SSG mode, the publisher runs Vite prerender with WEBSTUDIO_PRERENDER_ORIGIN=http://app:3000 (the internal Docker URL). This origin leaks into the generated HTML:

<meta property="og:url" content="http://app:3000/webinaire"/>
<meta property="og:image" content="/assets/W_binaire_EZfEexUXFny_KBxr3awKh.jpg"/>

Two issues:

  1. og:url contains the Docker-internal hostname instead of the public domain
  2. og:image is a relative path — social scrapers (WhatsApp, Slack, LinkedIn, Twitter) can't resolve it, especially when og:url is also broken

Fix

After the Vite build and before copying to /var/publish/, post-process all generated HTML files:

  • Replace every occurrence of BUILDER_INTERNAL_URL with https://<publishDomain>
  • Make og:image and twitter:image relative paths absolute

Test plan

  • Publish a SSG site and inspect the generated HTML: og:url should be https://<domain>/page
  • og:image should be an absolute URL (https://<domain>/assets/...)
  • Verify social preview works (e.g. via opengraph.xyz)

🤖 Generated with Claude Code

vianmora and others added 3 commits June 12, 2026 16:55
…enerated HTML

During SSG prerender, WEBSTUDIO_PRERENDER_ORIGIN=http://app:3000 leaks
into og:url in the generated HTML. og:image is also emitted as a relative
path, which social scrapers can't resolve.

Post-process all generated HTML files after Vite build:
- replace BUILDER_INTERNAL_URL occurrences with the public HTTPS domain
- make og:image / twitter:image relative paths absolute

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The publisher only checked vike's version to decide whether to reinstall.
When the webstudio CLI is upgraded, the generated package.json declares new
@webstudio-is/* versions but the cached node_modules still has the old ones,
causing "Missing specifier" errors (e.g. ./components in sdk-components-react).

Add a version check on sdk-components-react: if installed != declared, wipe
node_modules and reinstall.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The build runs once using publishDomain as canonical origin, then the same
dist/ is copied for each custom domain. Without rewriting, og:url in all
copies points to the wstdwork slug domain instead of the custom domain.

Refactor fixHtmlMeta into transformHtmlFiles(dir, transform) and apply a
second pass on each custom domain copy to replace publishDomain with the
custom domain.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vianmora vianmora merged commit 59f6bd6 into main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant