Conversation
pp-2741 Update dependencies, add Next.js dynamic imports, and refactor base path handling
Next.js serves page HTML at base path/subpaths (e.g. /p/test-nextjs/) rather than index.html.
Update predicate to match pathname.startsWith(base) && !pathname.includes('/_next/').
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/cli.ts`:
- Around line 985-988: The predicate that decides when to call mi.buildPage
currently uses pathname.startsWith(base) && !pathname.includes('/_next/'), which
also matches API routes (e.g., /.../api/...) and causes JSON responses to be
transformed; update the logic to either (A) tighten the predicate to explicitly
exclude API subpaths (e.g., ensure pathname does not contain '/api/' after the
base) where this match is computed, or (B) add a content-type guard inside
initRewriteResponse so it only calls mi.buildPage when the response has an HTML
content-type (e.g., Content-Type includes 'text/html' or
'application/xhtml+xml'); reference the predicate expression and the functions
initRewriteResponse and mi.buildPage when making the change.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/test-nextjs/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
README.mdsrc/cli.tstests/test-nextjs/pp-dev.config.ts
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
Fixes the rewrite response middleware for Next.js apps. The middleware was not rewriting HTML because the predicate only matched
index.html, while Next.js serves page HTML at base path and subpaths (e.g./p/test-nextjs/).Changes
pathname.startsWith(base) && !pathname.includes('/_next/')so it matches Next.js page URLs instead ofindex.htmlmiHudLessconfig and update package-lockTesting
Verified with test-nextjs app at base path; rewrite response middleware now rewrites page HTML as expected.
Summary by CodeRabbit
Documentation
Chores