fix-request-body.d.ts 738 B

12345678910111213141516171819202122
  1. import type * as http from 'node:http';
  2. export type BodyParserLikeRequest = http.IncomingMessage & {
  3. body?: any;
  4. };
  5. /**
  6. * Fix proxied body if bodyParser is involved.
  7. *
  8. * @example
  9. * ```ts
  10. * createProxyMiddleware({
  11. * target: 'http://example.com',
  12. * on: {
  13. * proxyReq: fixRequestBody,
  14. * }
  15. * });
  16. * ```
  17. *
  18. * Alternative solution without using `fixRequestBody()`: put `http-proxy-middleware` before `bodyParser` in the middleware stack.
  19. *
  20. * @see {@link https://github.com/chimurai/http-proxy-middleware/issues/40 Github issue #40 - POST request body is not proxied}
  21. */
  22. export declare function fixRequestBody<TReq extends BodyParserLikeRequest = BodyParserLikeRequest>(proxyReq: http.ClientRequest, req: TReq): void;