feat: add HTML landing page for SVG cards with robust content negotia… - #26
Merged
Chintanpatel24 merged 1 commit intoJun 11, 2026
Merged
Conversation
…tion Implement content negotiation in all API endpoints via a new `sendResponse` utility. This allows the same URL to serve a raw SVG when used in a GitHub README and a styled HTML landing page when a user clicks the card and opens it in a new tab. Key features: - Robust detection of browser navigation using `Sec-Fetch-Dest` and `Accept` headers. - Specifically detects GitHub Camo proxy to ensure SVGs are always served in READMEs. - HTML landing page centers the SVG and adds a footer with the project reference. - Includes `Vary: Accept, Sec-Fetch-Dest` for correct CDN caching. - Supports `?format=svg` query parameter to force raw SVG output. Updated all 10 API endpoints to use this new utility. Co-authored-by: Chintanpatel24 <216989679+Chintanpatel24@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds request-context-based content negotiation so a single card endpoint can return either raw SVG (for embedding, proxies) or an HTML landing page (for browser navigation).
Changes:
- Extends
sendResponseto detect browser navigation viaSec-Fetch-DestandAccept. - Adds
?format=svgoverride to force raw SVG output. - Updates caching behavior via
Varyheader for negotiated responses.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+33
to
+35
| if (secFetchDest === "document") { | ||
| serveHtml = true; | ||
| } |
Comment on lines
38
to
40
| res.setHeader("Content-Type", "text/html"); | ||
| res.setHeader("Vary", "Accept"); | ||
| res.setHeader("Vary", "Accept, Sec-Fetch-Dest"); | ||
| const html = ` |
Comment on lines
98
to
100
| res.setHeader("Content-Type", "image/svg+xml"); | ||
| res.setHeader("Vary", "Accept"); | ||
| res.setHeader("Vary", "Accept, Sec-Fetch-Dest"); | ||
| res.status(status).send(svg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…tion
Implement content negotiation in all API endpoints via a new
sendResponseutility. This allows the same URL to serve a raw SVG when used in a GitHub README and a styled HTML landing page when a user clicks the card and opens it in a new tab.Key features:
Sec-Fetch-DestandAcceptheaders.Vary: Accept, Sec-Fetch-Destfor correct CDN caching.?format=svgquery parameter to force raw SVG output.Updated all 10 API endpoints to use this new utility.