fix(router): middleware in index + routeLoader handling#8697
Conversation
🦋 Changeset detectedLatest commit: 021b4ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR adjusts Qwik Router’s request-handler resolution so that, for q-loader (per-routeLoader) JSON requests, middleware defined in the final page/index module is only executed when the requested loader is actually exported by that same page module. This prevents index-level middleware from running for loader requests targeting layout/root loaders on the same path.
Changes:
- Guard page/index module request handlers during
q-loaderrequests based on the requested loader id. - Refactor handler extraction into helper functions to support the guarding behavior.
- Add unit tests covering the new
q-loader+ page middleware behavior, and include a router changeset entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/qwik-router/src/middleware/request-handler/resolve-request-handlers-core.ts | Adds guarding logic for last page module handlers during q-loader requests and refactors handler collection. |
| packages/qwik-router/src/middleware/request-handler/resolve-request-handlers.unit.ts | Adds unit tests validating that page/index middleware is skipped or executed appropriately for loader requests. |
| .changeset/spicy-squids-count.md | Records the patch-level behavioral fix in release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| '@qwik.dev/router': patch | ||
| --- | ||
|
|
||
| FIX: don't run middleware defined in index.\* for a routeloader on the same path, unless the routeloader is defined in index |
@qwik.dev/core
@qwik.dev/router
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
commit: |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Edge case, but important