@types/http-proxy

  • Version 1.17.7
  • Published
  • 12.8 kB
  • 1 dependency
  • MIT license

Install

npm i @types/http-proxy
yarn add @types/http-proxy
pnpm add @types/http-proxy

Overview

TypeScript definitions for node-http-proxy

Index

Classes

class Server

class Server extends events.EventEmitter {}

    constructor

    constructor(options?: Server.ServerOptions);
    • Creates the proxy server with specified options.

      Parameter options

      Config object passed to the proxy

    method addListener

    addListener: (event: string, listener: () => void) => this;

      method close

      close: (callback?: () => void) => void;
      • A function that closes the inner webserver and stops listening on given port

      method createProxy

      static createProxy: (options?: Server.ServerOptions) => Server;
      • Creates the proxy server with specified options.

        Parameter options

        Config object passed to the proxy

        Returns

        Proxy object with handlers for ws and web requests

      method createProxyServer

      static createProxyServer: (options?: Server.ServerOptions) => Server;
      • Creates the proxy server with specified options.

        Parameter options

        Config object passed to the proxy

        Returns

        Proxy object with handlers for ws and web requests

      method createServer

      static createServer: (options?: Server.ServerOptions) => Server;
      • Creates the proxy server with specified options.

        Parameter options

        Config object passed to the proxy

        Returns

        Proxy object with handlers for ws and web requests

      method emit

      emit: (event: string, ...args: any[]) => boolean;

        method getMaxListeners

        getMaxListeners: () => number;

          method listen

          listen: (port: number) => Server;
          • A function that wraps the object in a webserver, for your convenience

            Parameter port

            Port to listen on

          method listenerCount

          listenerCount: (type: string) => number;

            method listeners

            listeners: (event: string) => Array<() => void>;

              method on

              on: {
              (event: string, listener: () => void): this;
              (event: 'error', listener: Server.ErrorCallback): this;
              (event: 'start', listener: Server.StartCallback): this;
              (event: 'proxyReq', listener: Server.ProxyReqCallback): this;
              (event: 'proxyRes', listener: Server.ProxyResCallback): this;
              (event: 'proxyReqWs', listener: Server.ProxyReqWsCallback): this;
              (event: 'econnreset', listener: Server.EconnresetCallback): this;
              (event: 'end', listener: Server.EndCallback): this;
              (event: 'open', listener: Server.OpenCallback): this;
              (event: 'close', listener: Server.CloseCallback): this;
              };

                method once

                once: {
                (event: string, listener: () => void): this;
                (event: 'error', listener: Server.ErrorCallback): this;
                (event: 'start', listener: Server.StartCallback): this;
                (event: 'proxyReq', listener: Server.ProxyReqCallback): this;
                (event: 'proxyRes', listener: Server.ProxyResCallback): this;
                (event: 'proxyReqWs', listener: Server.ProxyReqWsCallback): this;
                (event: 'econnreset', listener: Server.EconnresetCallback): this;
                (event: 'end', listener: Server.EndCallback): this;
                (event: 'open', listener: Server.OpenCallback): this;
                (event: 'close', listener: Server.CloseCallback): this;
                };

                  method removeAllListeners

                  removeAllListeners: (event?: string) => this;

                    method removeListener

                    removeListener: (event: string, listener: () => void) => this;

                      method setMaxListeners

                      setMaxListeners: (n: number) => this;

                        method web

                        web: (
                        req: any,
                        res: any,
                        options?: Server.ServerOptions,
                        callback?: Server.ErrorCallback
                        ) => void;
                        • Used for proxying regular HTTP(S) requests

                          Parameter req

                          Client request.

                          Parameter res

                          Client response.

                          Parameter options

                          Additionnal options.

                        method ws

                        ws: (
                        req: any,
                        socket: any,
                        head: any,
                        options?: Server.ServerOptions,
                        callback?: Server.ErrorCallback
                        ) => void;
                        • Used for proxying regular HTTP(S) requests

                          Parameter req

                          Client request.

                          Parameter socket

                          Client socket.

                          Parameter head

                          Client head.

                          Parameter options

                          Additionnal options.

                        Interfaces

                        interface ServerOptions

                        interface ServerOptions {}

                          property agent

                          agent?: any;
                          • Object to be passed to http(s).request.

                          property auth

                          auth?: string | undefined;
                          • Basic authentication i.e. 'user:password' to compute an Authorization header.

                          property autoRewrite

                          autoRewrite?: boolean | undefined;
                          • Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false.

                          property buffer

                          buffer?: stream.Stream | undefined;
                          • Buffer

                          property changeOrigin

                          changeOrigin?: boolean | undefined;
                          • Changes the origin of the host header to the target URL.

                          property cookieDomainRewrite

                          cookieDomainRewrite?:
                          | false
                          | string
                          | { [oldDomain: string]: string }
                          | undefined;
                          • rewrites domain of set-cookie headers.

                          property cookiePathRewrite

                          cookiePathRewrite?: false | string | { [oldPath: string]: string } | undefined;
                          • rewrites path of set-cookie headers. Default: false

                          property followRedirects

                          followRedirects?: boolean | undefined;
                          • Specify whether you want to follow redirects. Default: false

                          property forward

                          forward?: ProxyTargetUrl | undefined;
                          • URL string to be parsed with the url module.

                          property headers

                          headers?: { [header: string]: string } | undefined;
                          • object with extra headers to be added to target requests.

                          property hostRewrite

                          hostRewrite?: string | undefined;
                          • Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null.

                          property ignorePath

                          ignorePath?: boolean | undefined;
                          • Specify whether you want to ignore the proxy path of the incoming request.

                          property localAddress

                          localAddress?: string | undefined;
                          • Local interface string to bind for outgoing connections.

                          property prependPath

                          prependPath?: boolean | undefined;
                          • Specify whether you want to prepend the target's path to the proxy path.

                          property preserveHeaderKeyCase

                          preserveHeaderKeyCase?: boolean | undefined;
                          • specify whether you want to keep letter case of response header key

                          property protocolRewrite

                          protocolRewrite?: string | undefined;
                          • Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null.

                          property proxyTimeout

                          proxyTimeout?: number | undefined;
                          • Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes)

                          property secure

                          secure?: boolean | undefined;
                          • Verify SSL certificate.

                          property selfHandleResponse

                          selfHandleResponse?: boolean | undefined;
                          • If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event

                          property ssl

                          ssl?: any;
                          • Object to be passed to https.createServer().

                          property target

                          target?: ProxyTarget | undefined;
                          • URL string to be parsed with the url module.

                          property timeout

                          timeout?: number | undefined;
                          • Timeout (in milliseconds) for incoming requests

                          property toProxy

                          toProxy?: boolean | undefined;
                          • Explicitly specify if we are proxying to another proxy.

                          property ws

                          ws?: boolean | undefined;
                          • If you want to proxy websockets.

                          property xfwd

                          xfwd?: boolean | undefined;
                          • Adds x- forward headers.

                          Type Aliases

                          type CloseCallback

                          type CloseCallback = (
                          proxyRes: http.IncomingMessage,
                          proxySocket: net.Socket,
                          proxyHead: any
                          ) => void;

                            type EconnresetCallback

                            type EconnresetCallback = (
                            err: Error,
                            req: http.IncomingMessage,
                            res: http.ServerResponse,
                            target: ProxyTargetUrl
                            ) => void;

                              type EndCallback

                              type EndCallback = (
                              req: http.IncomingMessage,
                              res: http.ServerResponse,
                              proxyRes: http.IncomingMessage
                              ) => void;

                                type ErrorCallback

                                type ErrorCallback = (
                                err: Error,
                                req: http.IncomingMessage,
                                res: http.ServerResponse,
                                target?: ProxyTargetUrl
                                ) => void;

                                  type OpenCallback

                                  type OpenCallback = (proxySocket: net.Socket) => void;

                                    type ProxyReqCallback

                                    type ProxyReqCallback = (
                                    proxyReq: http.ClientRequest,
                                    req: http.IncomingMessage,
                                    res: http.ServerResponse,
                                    options: ServerOptions
                                    ) => void;

                                      type ProxyReqWsCallback

                                      type ProxyReqWsCallback = (
                                      proxyReq: http.ClientRequest,
                                      req: http.IncomingMessage,
                                      socket: net.Socket,
                                      options: ServerOptions,
                                      head: any
                                      ) => void;

                                        type ProxyResCallback

                                        type ProxyResCallback = (
                                        proxyRes: http.IncomingMessage,
                                        req: http.IncomingMessage,
                                        res: http.ServerResponse
                                        ) => void;

                                          type ProxyTarget

                                          type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;

                                            type ProxyTargetUrl

                                            type ProxyTargetUrl = string | Partial<url.Url>;

                                              type StartCallback

                                              type StartCallback = (
                                              req: http.IncomingMessage,
                                              res: http.ServerResponse,
                                              target: ProxyTargetUrl
                                              ) => void;

                                                Package Files (1)

                                                Dependencies (1)

                                                Dev Dependencies (0)

                                                No dev dependencies.

                                                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/@types/http-proxy.

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