Fix OG Image Route to Use Direct Data Imports for Accurate Stats#8271
Fix OG Image Route to Use Direct Data Imports for Accurate Stats#8271ionfwsrijan wants to merge 0 commit into
Conversation
|
@ionfwsrijan is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request addresses a critical issue with the OG image generator by replacing the problematic fetch call with direct imports of necessary functions. This change ensures that the OG image displays accurate user contribution statistics without encountering JSON parse errors. This approach aligns with previous decisions made to enhance the reliability of the image generation process. Thank you for your contribution! |
|
🚨 Hey @ionfwsrijan, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
3846ad4 to
61ec3f9
Compare
Description
The OG image generator at
app/api/og/route.tsxwas fetching/api/streak?user=...&refresh=trueand callingres.json()on the response. However, the/api/streakendpoint returns animage/svg+xmlresponse, not JSON. Theres.json()call always threw a parse error silently swallowed by the emptycatch {}block, causing every OG preview image to display 0/0/0 regardless of the user's actual stats.Fix
Replaced the self-referencing HTTP fetch to the SVG-producing API route with direct imports of
fetchGitHubContributionsfromlib/githubandcalculateStreakfromlib/calculate. Both functions work in the edge runtime and return structured data directly.Changes
app/api/og/route.tsx: Removedfetch(\${baseUrl}/api/streak?user=...`)call, added imports forfetchGitHubContributionsandcalculateStreak`, call data functions directlyChecklist
CONTRIBUTING.mdfileFixes #8267