dev.setupMiddlewares

  • Type:
type RequestHandler = (req: any, res: any, next: () => void) => void;

type ExposeServerApis = {
  sockWrite: (
    type: string,
    data?: string | boolean | Record<string, any>,
  ) => void;
};

type SetupMiddlewares = Array<
  (
    middlewares: {
      unshift: (...handlers: RequestHandler[]) => void;
      push: (...handlers: RequestHandler[]) => void;
    },
    server: ExposeServerApis,
  ) => void
>;
  • Default: undefined

Provides the ability to execute a custom function and apply custom middlewares.

Info

The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to Rsbuild - dev.setupMiddlewares.