http-proxy-middleware

  • Version 2.0.1
  • Published
  • 63.6 kB
  • 5 dependencies
  • MIT license

Install

npm i http-proxy-middleware
yarn add http-proxy-middleware
pnpm add http-proxy-middleware

Overview

The one-liner node.js proxy middleware for connect, express and browser-sync

Index

Functions

function createProxyMiddleware

createProxyMiddleware: (
context: Filter | Options,
options?: Options
) => import('./types').RequestHandler;

    function fixRequestBody

    fixRequestBody: (proxyReq: any, req: any) => void;
    • Fix proxied body if bodyParser is involved.

    function responseInterceptor

    responseInterceptor: (
    interceptor: Interceptor
    ) => (proxyRes: any, req: any, res: any) => Promise<void>;
    • Intercept responses from upstream. Automatically decompress (deflate, gzip, brotli). Give developer the opportunity to modify intercepted Buffer and http.ServerResponse

      NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())

    Interfaces

    interface Options

    interface Options extends httpProxy.ServerOptions {}

      property logLevel

      logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';

        property logProvider

        logProvider?: LogProviderCallback;

          property onClose

          onClose?: OnCloseCallback;

            property onError

            onError?: OnErrorCallback;

              property onOpen

              onOpen?: OnOpenCallback;

                property onProxyReq

                onProxyReq?: OnProxyReqCallback;

                  property onProxyReqWs

                  onProxyReqWs?: OnProxyReqWsCallback;

                    property onProxyRes

                    onProxyRes?: OnProxyResCallback;

                      property pathRewrite

                      pathRewrite?:
                      | {
                      [regexp: string]: string;
                      }
                      | ((path: string, req: Request) => string)
                      | ((path: string, req: Request) => Promise<string>);

                        property router

                        router?:
                        | {
                        [hostOrPath: string]: httpProxy.ServerOptions['target'];
                        }
                        | ((req: Request) => httpProxy.ServerOptions['target'])
                        | ((req: Request) => Promise<httpProxy.ServerOptions['target']>);

                          interface RequestHandler

                          interface RequestHandler extends express.RequestHandler {}

                            property upgrade

                            upgrade?: (req: Request, socket: net.Socket, head: any) => void;

                              Type Aliases

                              type Filter

                              type Filter = string | string[] | ((pathname: string, req: Request) => boolean);

                                Package Files (4)

                                Dependencies (5)

                                Dev Dependencies (29)

                                Peer Dependencies (0)

                                No peer dependencies.

                                Badge

                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/http-proxy-middleware.

                                • Markdown
                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/http-proxy-middleware)
                                • HTML
                                  <a href="https://www.jsdocs.io/package/http-proxy-middleware"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>