fix: exclude og-image from global route rule with enabled isr#962
fix: exclude og-image from global route rule with enabled isr#962danielroe merged 2 commits intonpmx-dev:mainfrom
Conversation
|
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! |
📝 WalkthroughWalkthroughAdds a new Nuxt route rule for the og image endpoint ( 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
nuxt.config.ts (1)
86-91:⚠️ Potential issue | 🟡 MinorRestructure routeRules to avoid wildcard cache precedence issue.
Nitro's route matching engine (radix3/rou3) allows multiple rules to match a single request. Setting
isr: falseon'/__og-image__/**'does not reliably override the catch-all'/**'ISR rule due to a known Nitro limitation (nitrojs/nitro#1751). OG-image routes may still receive ISR caching from the wildcard rule, causing cache issues.Restructure to avoid wildcard cache rules: instead of
'/**': { isr: getISRConfig(60, true) }, apply ISR explicitly to specific paths that need it ('/','/opensearch.xml','/api/**', etc.) and keep OG-image routes explicitly uncached.
What
Currently, uncached images often return an error (followed by an additional redirect). Because of this, even if a preview is returned, it doesn't contain a valid image.
How
The problem is known and common, but the author of og-image writes that the only way to solve it is to manually define all the routes. However, it was enough to simply explicitly override exact rule that were defined under the global rule
Test
Open the path /og-image/image/package/{PACKAGE_NAME}/og.png
It should wait for the image to be generated (for comparison, you can go to production for unpopular packages)
Closes #960