Skip to content

Start: request param is undefined in request middleware when used in server function #5384

Closed

Description

@andybons

Which project does this relate to?

Start

Describe the bug

When using a request middleware in a server function, the request parameter passed to it is undefined while getRequest() correctly returns it:

const requestMiddleware = createMiddleware({ type: "request" }).server(
  async ({ next, request }) => {
    return next({
      context: {
        requestParam: request?.url, <-- request is undefined
        requestFunc: getRequest().url,
      },
    });
  }
);

const serverFn = createServerFn()
  .middleware([requestMiddleware])
  .handler(async ({ context: { requestParam, requestFunc } }) => {
    return { requestParam, requestFunc };
  });

Your Example Website or App

https://codesandbox.io/p/devbox/composed-middleware-typing-issue-1-132-7-forked-zkxl87

Steps to Reproduce the Bug or Issue

  1. Click reproduction url
  2. Observe requestParam is undefined

Expected behavior

I expect the request param passed to a middleware to be equal to getRequest

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.132.41
  • Bundler: Vite
  • Bundler Version: 7.1.9

Additional context

No response

Activity

  1. added a commit that references this issue on Oct 6, 2025
    28d5b99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions