fix: pass query params to OG image ISR function on Vercel#2432
fix: pass query params to OG image ISR function on Vercel#2432Adebesin-Cell wants to merge 2 commits intonpmx-dev:mainfrom
Conversation
Vercel's ISR `passQuery` defaults to `false`, which strips all query parameters before passing the request to the serverless function. This caused the compare page OG image to always render the empty state because the function never received `packages=zustand,redux` or the `_query` parameter that nuxt-og-image relies on. Closes npmx-dev#2431 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Nuxt Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
nuxt.config.ts (1)
132-135: Add query parameter whitelist to explicitly constrain OG image cache variation
passQuery: truecorrectly makes query parameters available to the OG image handler. However, to ensure robust caching behaviour and prevent unintended cache fragmentation, explicitly specify which query parameters should affect the cache key usingallowQuery. By default, query parameters are ignored for cache keying unless listed inallowQuery, so adding this constraint makes the caching intent clear and ensures only the parameters the handler actually needs will vary the cache.Suggested hardening
'/__og-image__/**': { isr: { expiration: 3600, passQuery: true, + allowQuery: ['packages', '_query'], }, },Verify which query parameters the OG image handler requires and update the
allowQuerylist accordingly.
Restrict cache variation to only the query params the OG handler needs, preventing cache fragmentation from arbitrary query params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
passQuery: trueto the/__og-image__/**ISR route rulepassQuerydefaults tofalse, which strips all query parameters before passing the request to the serverless functionpackages=zustand,reduxor the_queryparameter thatnuxt-og-imagerelies onRoot cause
Vercel's prerender config has a
passQueryoption that defaults tofalse. Without it, the ISR function receives the request with query params stripped — so the OG image handler always fetched/compare(no packages) instead of/compare?packages=zustand,redux.Test plan
/compare?packages=zustand,redux/__og-image__/image/compare/og.html?packages=zustand,redux&_query=%7B%22packages%22:%22zustand,redux%22%7Dshows package namesCloses #2431