Skip to content

fix: exclude og-image from global route rule with enabled isr#962

Merged
danielroe merged 2 commits intonpmx-dev:mainfrom
alexdln:fix/og-image-route-render
Feb 5, 2026
Merged

fix: exclude og-image from global route rule with enabled isr#962
danielroe merged 2 commits intonpmx-dev:mainfrom
alexdln:fix/og-image-route-render

Conversation

@alexdln
Copy link
Contributor

@alexdln alexdln commented Feb 4, 2026

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

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 4, 2026 6:53pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 4, 2026 6:53pm
npmx-lunaria Ignored Ignored Feb 4, 2026 6:53pm

Request Review

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Adds a new Nuxt route rule for the og image endpoint (/__og-image__/**) setting isr to getISRConfig(60) (no fallback), while retaining the existing /** route rule with isr: getISRConfig(60, true) (with fallback). No other route rules or exported/public entity signatures were changed.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly explains the problem (uncached images returning errors), the solution (explicitly overriding route rules for og-image), and provides testing instructions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Restructure routeRules to avoid wildcard cache precedence issue.

Nitro's route matching engine (radix3/rou3) allows multiple rules to match a single request. Setting isr: false on '/__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.

@danielroe danielroe added this pull request to the merge queue Feb 5, 2026
Merged via the queue into npmx-dev:main with commit 76af2ff Feb 5, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: serving uncached images

2 participants