For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/configure/app/dev/setup-middlewares.md.
  • 简体中文
  • dev.setupMiddlewares

    • 类型:
    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
    >;
    • 默认值: undefined

    提供执行自定义函数和应用自定义中间件的能力。

    Info

    该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 Rsbuild - dev.setupMiddlewares。