Skip to content

Conversation

rururux
Copy link
Contributor

@rururux rururux commented Oct 11, 2025

fixes #14429

Previously, routes that only defined an action and had middleware could fail to
invoke the action unless at least one loader was present in the matched route tree.
This patch ensures the middleware execution path correctly handles action-only routes by always executing the
action phase even when no loaders are found.

@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2025

🦋 Changeset detected

Latest commit: 7e53983

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

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router 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

middleware && middleware.length > 0 && !loader && !lazy;
middleware && middleware.length > 0 && !loader && !action && !lazy;

if (callHandler && !isMiddlewareOnlyRoute) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (callHandler && !isMiddlewareOnlyRoute) {
if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {

Copy link
Contributor

@brophdawg11 brophdawg11 left a comment

Choose a reason for hiding this comment

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

Thanks! I changed the fix up slightly to limit the loader/lazy check to GET requests only

@brophdawg11 brophdawg11 merged commit 0163df4 into remix-run:dev Oct 23, 2025
5 checks passed
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 7.9.5-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@rururux
Copy link
Contributor Author

rururux commented Oct 23, 2025

thank you! 😆

@rururux rururux deleted the middleware-action-only-route branch October 23, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants