Skip to content

fix(router): middleware in index + routeLoader handling#8697

Merged
wmertens merged 1 commit into
build/v2from
fix-loader-middleware
Jun 5, 2026
Merged

fix(router): middleware in index + routeLoader handling#8697
wmertens merged 1 commit into
build/v2from
fix-loader-middleware

Conversation

@wmertens

@wmertens wmertens commented Jun 5, 2026

Copy link
Copy Markdown
Member

Edge case, but important

Copilot AI review requested due to automatic review settings June 5, 2026 12:36
@wmertens wmertens requested a review from a team as a code owner June 5, 2026 12:36
@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 021b4ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/router Patch
eslint-plugin-qwik Patch
@qwik.dev/core Patch
create-qwik Patch
@qwik.dev/react Patch

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

Copilot AI 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.

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-loader requests 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
@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8697

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8697

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8697

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8697

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8697

commit: 021b4ce

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 021b4ce

@wmertens wmertens merged commit 34f8ff2 into build/v2 Jun 5, 2026
33 checks passed
@wmertens wmertens deleted the fix-loader-middleware branch June 5, 2026 13:32
@github-project-automation github-project-automation Bot moved this from Waiting For Review to Done in Qwik Development Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants