Skip to content

PP-2836 fix(nextjs): rewrite response middleware for Next.js page URLs - #49

Merged
sergak01 merged 4 commits into
developfrom
pp-2836
Feb 24, 2026
Merged

PP-2836 fix(nextjs): rewrite response middleware for Next.js page URLs#49
sergak01 merged 4 commits into
developfrom
pp-2836

Conversation

@sergak01

@sergak01 sergak01 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

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

  • fix(nextjs): Update predicate to pathname.startsWith(base) && !pathname.includes('/_next/') so it matches Next.js page URLs instead of index.html
  • chore(test-nextjs): Add miHudLess config and update package-lock
  • docs: Update CI badges for pp-dev repo

Testing

Verified with test-nextjs app at base path; rewrite response middleware now rewrites page HTML as expected.

Summary by CodeRabbit

  • Documentation

    • Updated README workflow badges to independently display release and continuous integration pipeline statuses.
  • Chores

    • Optimized middleware request handling by differentiating processing logic between internal framework routes and application routes for improved request efficiency.
    • Extended test configuration with new feature flag options to support additional testing scenarios and configurations.

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/').
@sergak01 sergak01 self-assigned this Feb 24, 2026
@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pp-2836

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between eb24b76 and c4b94be.

⛔ Files ignored due to path filters (1)
  • tests/test-nextjs/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • README.md
  • src/cli.ts
  • tests/test-nextjs/pp-dev.config.ts

Comment thread src/cli.ts
@sergak01
sergak01 merged commit 5379d25 into develop Feb 24, 2026
3 checks passed
@sergak01
sergak01 deleted the pp-2836 branch February 24, 2026 16:51
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.

1 participant