Skip to content

make asset and opengraph paths deployment-origin aware - #7

Merged
dbertram merged 1 commit into
mainfrom
fix-asset-urls
Apr 8, 2026
Merged

make asset and opengraph paths deployment-origin aware#7
dbertram merged 1 commit into
mainfrom
fix-asset-urls

Conversation

@dbertram

@dbertram dbertram commented Apr 8, 2026

Copy link
Copy Markdown
Owner
  • make vite assets use relative URLs (we were sloppily setting viteOptions.base before, but it wasn't working for things like Netlify branch deploys)
  • compute a deployOrigin based on Netlify and Eleventy env vars and use that to make og:url and og:image use absoluate URLs with deployment-appropriate origins
  • I couldn't find a clean/simple way to use fingerprinted assets output from Vite use deployment-origin aware absolute URLs, so instead I made a duplicate copy of the avatar image that lives in public (and is therefore not fingerprinted) so we can pipe it through a filter to make it absolute

The downside of this approach is a second copy of the same image, but it won't be loaded in the browser, only for things trying to generate an OpenGraph preview (i.e., 2 copies, but only one should ever be loaded by any given client).

- make vite assets use relative URLs (we were sloppily setting viteOptions.base before, but it wasn't working for things like Netlify branch deploys)
- compute a deployOrigin based on Netlify and Eleventy env vars and use that to make og:url and og:image use absoluate URLs with deployment-appropriate origins
- I couldn't find a clean/simple way to use fingerprinted assets output from Vite use deployment-origin aware absolute URLs, so instead I made a duplicate copy of the avatar image that lives in public (and is therefore not fingerprinted) so we can pipe it through a filter to make it absolute

The downside of this approach is a second copy of the same image, but it won't be loaded in the browser, only for things trying to generate an OpenGraph preview (i.e., 2 copies, but only one should ever be loaded by any given client).
@netlify

netlify Bot commented Apr 8, 2026

Copy link
Copy Markdown

Deploy Preview for danebertram ready!

Name Link
🔨 Latest commit e813dfe
🔍 Latest deploy log https://app.netlify.com/projects/danebertram/deploys/69d5b9d492b0a500074a2122
😎 Deploy Preview https://deploy-preview-7--danebertram.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dbertram
dbertram merged commit 0b90b39 into main Apr 8, 2026
5 checks passed
@dbertram
dbertram deleted the fix-asset-urls branch April 8, 2026 02:15
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