TanStackT
TanStack12mo ago
3 replies
forward-apricot

registerGlobalMiddleware not working

Hello everyone,

I am trying to use the registerGlobalMiddleware but it never calls the middlewares that define in it.

For example the following code never gets executed whenever I press the increment btn (from the doc demo).

Is this behaviour expected ?

const globalMiddleware1 = createMiddleware().server(async ({ next }) => {
  console.log("globalMiddleware1");
  return next();
});

registerGlobalMiddleware({
  middleware: [globalMiddleware1],
});


Here is the reproduction step:

npx degit https://github.com/tanstack/router/examples/react/start-basic start-basic
cd start-basic
npm install
npm run dev

and then copy the code block above into the __root. Then go to the Deferred page and click the increment btn. At this point I was expecting a log in my server terminal.
Was this page helpful?