feat: render sponsor/track logos from HARP logo_url via next/image - #9
Merged
Merged
Conversation
HARP's public API now returns logo_url (keyless, versioned, immutable cache) instead of inline base64 logo_data. Consume it with next/image and allow-list the HARP host in images.remotePatterns.
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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
Companion to hackutd/hackutd-harp#15. HARP's
/v1/public/sponsorsand/v1/public/tracksno longer inline base64logo_data; they returnserved keyless with
ETag+Cache-Control: public, max-age=31536000, immutable. This PR consumes that so logos stop being embedded asdata:URIs in the page HTML (every visitor was downloading every logo, uncached and unresized) and instead go throughnext/image→ Vercel image optimizer/CDN + browser cache.lib/types.ts:Sponsor/Trackdroplogo_data/logo_content_type, gainlogo_url: string.lib/api.ts: track validation swaps the content-type check forisTrackLogoUrl(""or absolute http(s)).lib/format.ts:sponsorLogoSrc(data, contentType)→logoSrc(url); passes through http(s) only, null otherwise so callers keep their monogram / text-only fallbacks. Shared by both components.components/sponsor-logo.tsx,components/challenge-tracks.tsx:<img src="data:...">→<Image>(fillin ah-16box for sponsors;96×48for tracks).next.config.ts:images.remotePatternsis derived fromHARP_API_BASE_URLat build time, restricted topathname: "/v1/public/*/*/logo"(query left open because?v=varies). Deploy note:HARP_API_BASE_URLmust be present in the Vercel build environment, not just runtime — it already is if it's set as a normal env var, but if it's missing at build time remote logos will 400 from the optimizer. Upstreamimmutablemax-age makes Next cache optimized variants for the full year (docs: TTL is max(minimumCacheTTL, upstream))..env.exampleupdated accordingly.Must be deployed together with (or after) the HARP PR — until then
logo_urlis absent and every sponsor renders the monogram / tracks render text-only (no crash; validation treats missing field as invalid tracks payload, so the tracks section shows its unavailable state).Checks:
lint,format:check,typecheck,next build(withHARP_API_BASE_URLset) pass.Link to Devin session: https://app.devin.ai/sessions/919a1d99cd6c4f7d9452edb8a04fe394
Open in Devin Desktop: https://app.devin.ai/desktop/session/919a1d99cd6c4f7d9452edb8a04fe394?variant=devin
Requested by: @balebbae