Skip to content

Add fallback OG in the event of 404 - #13

Merged
mrdarrengriffin merged 1 commit into
mainfrom
esphome-template-fallback
Jul 2, 2026
Merged

Add fallback OG in the event of 404#13
mrdarrengriffin merged 1 commit into
mainfrom
esphome-template-fallback

Conversation

@mrdarrengriffin

Copy link
Copy Markdown
Member

TSIA

Copilot AI review requested due to automatic review settings July 2, 2026 15:08
@netlify

netlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploy Preview for ohf-assets ready!

Name Link
🔨 Latest commit 32f661f
🔍 Latest deploy log https://app.netlify.com/projects/ohf-assets/deploys/6a467f0aea7c0d0008a771ae
😎 Deploy Preview https://deploy-preview-13--ohf-assets.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@mrdarrengriffin
mrdarrengriffin merged commit 0460e1a into main Jul 2, 2026
5 checks passed
@mrdarrengriffin
mrdarrengriffin deleted the esphome-template-fallback branch July 2, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a template-level fallback Open Graph image that is served when the target page fetch fails (e.g., 404), so OG requests can still return a valid image instead of a 500.

Changes:

  • Adds fallbackImage support to template configs (starting with the esphome template).
  • Introduces loadFallbackImage() in lib/templates.mjs to load and serve the configured fallback asset with an appropriate MIME type.
  • Updates both the local dev server and the Netlify function to return the fallback image when the page fetch is not OK or throws.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
templates/esphome/config.json Declares fallbackImage: "og.webp" for the ESPHome template.
server.mjs Serves the configured fallback image when /opengraph fetch returns non-OK or errors.
netlify/functions/opengraph.mjs Mirrors the same fallback behavior in the Netlify OG endpoint.
lib/templates.mjs Adds loadFallbackImage() to load the configured fallback asset and determine its MIME type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants