factory-hono.d.ts 986 B

12345678910111213141516171819202122232425262728
  1. import type { HttpBindings } from '@hono/node-server';
  2. import type { MiddlewareHandler } from 'hono';
  3. import { type Options } from './index.js';
  4. /**
  5. * Creates a Hono middleware that proxies requests using http-proxy-middleware.
  6. *
  7. * @remarks
  8. * This middleware requires Hono to be running on Node.js via `@hono/node-server`.
  9. * It uses `c.env.incoming` and `c.env.outgoing` which are only available with `HttpBindings`.
  10. *
  11. * @experimental This API is experimental and may change without a major version bump.
  12. *
  13. * @example
  14. * ```ts
  15. * import { serve } from '@hono/node-server';
  16. * import { Hono } from 'hono';
  17. * import { createHonoProxyMiddleware } from 'http-proxy-middleware/hono';
  18. *
  19. * const app = new Hono();
  20. * app.use('/api', createHonoProxyMiddleware({ target: 'http://example.com', changeOrigin: true }));
  21. * serve(app);
  22. * ```
  23. *
  24. * @since 4.0.0
  25. */
  26. export declare function createHonoProxyMiddleware(options: Options): MiddlewareHandler<{
  27. Bindings: HttpBindings;
  28. }>;