Redirect assets through jsDelivr with GitHub raw fallback#1270
Merged
Conversation
jsDelivr serves the same files multi-CDN with 7-day client caching, versus 5 minutes on raw.githubusercontent.com. A 30s health check promotes jsDelivr after two consecutive successes and falls back to GitHub raw after two consecutive failures; FORCE_GITHUB_CDN=true pins the legacy behavior. Redirects switch from 308 to 307 with a 300s Cache-Control so a CDN switch propagates within minutes instead of being pinned forever by browser-cached permanent redirects. A workflow purges changed files from the jsDelivr cache on merge so freshly added logos are available immediately.
The fallback query param let the daemon http.Get an arbitrary client-supplied URL and stream the bytes back on our own origin. That was a server-side request forgery vector (probing the host's internal network) and, if the UI is ever served from this same domain, a reflected same-origin XSS sink (an attacker SVG rendered as a top-level document on our origin). Redirect the browser to the URL instead: the daemon makes no outbound request, and the fallback image renders on its own origin, never ours. Restricted to http(s) so the Location cannot carry a javascript: or data: scheme. The fallback=true path (static built-in images) is unchanged.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Implements CDN-based asset delivery through jsDelivr with automatic fallback to GitHub raw content. Fallback handling now uses HTTP redirects instead of server-side fetching, reducing server load. Adds a workflow to purge jsDelivr cache when needed.
What changed
Risks
Test plan
Docs impact
Documentation should be updated to explain the new CDN redirect behavior, fallback mechanism, and how to manually trigger cache purges via the new workflow.
Breaking changes
Fallback asset delivery now uses HTTP redirects instead of server-side fetching. Clients that don't follow redirects will fail to retrieve assets through the fallback path.