Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PassThroughHandlerOptions

Hierarchy

  • PassThroughHandlerOptions

Index

Properties

clientCertificateHostMap?: {}

A mapping of hosts to client certificates to use, in the form of { key, cert } objects (none, by default)

Type declaration

  • [host: string]: { passphrase?: string; pfx: Buffer }
    • Optional passphrase?: string
    • pfx: Buffer
forwarding?: ForwardingOptions

The forwarding configuration for the passthrough rule. This generally shouldn't be used explicitly unless you're building rule data by hand. Instead, call thenPassThrough to send data directly or thenForwardTo with options to configure traffic forwarding.

ignoreHostCertificateErrors?: string[]

Deprecated alias for ignoreHostHttpsErrors.

deprecated
ignoreHostHttpsErrors?: string[]

A list of hostnames for which server certificate and TLS version errors should be ignored (none, by default).

lookupOptions?: PassThroughLookupOptions

Custom DNS options, to allow configuration of the resolver used when forwarding requests upstream. Passing any option switches from using node's default dns.lookup function to using the cacheable-lookup module, which will cache responses.

proxyConfig?: ProxyConfig

Upstream proxy configuration: pass through requests via this proxy.

If this is undefined, no proxy will be used. To configure a proxy provide either:

  • a ProxySettings object
  • a callback which will be called with an object containing the hostname, and must return a ProxySettings object or undefined.
  • an array of ProxySettings or callbacks. The array will be processed in order, and the first not-undefined ProxySettings found will be used.

When using a remote client, this parameter or individual array values may be passed by reference, using the name of a rule parameter configured in the standalone server.

transformRequest?: RequestTransform

A set of data to automatically transform a request. This includes properties to support many transformation common use cases.

For advanced cases, a custom callback using beforeRequest can be used instead. Using this field however where possible is typically simpler, more declarative, and can be more performant. The two options are mutually exclusive: you cannot use both transformRequest and a beforeRequest callback.

Only one transformation for each target (method, headers & body) can be specified. If more than one is specified then an error will be thrown when the rule is registered.

transformResponse?: ResponseTransform

A set of data to automatically transform a response. This includes properties to support many transformation common use cases.

For advanced cases, a custom callback using beforeResponse can be used instead. Using this field however where possible is typically simpler, more declarative, and can be more performant. The two options are mutually exclusive: you cannot use both transformResponse and a beforeResponse callback.

Only one transformation for each target (status, headers & body) can be specified. If more than one is specified then an error will be thrown when the rule is registered.

Methods

  • A callback that will be passed the full request before it is passed through, and which returns an object that defines how the the request content should be transformed before it's passed to the upstream server.

    The callback can return an object to define how the request should be changed. All fields on the object are optional, and returning undefined is equivalent to returning an empty object (transforming nothing). The possible fields are:

    • method (a replacement HTTP verb, capitalized)
    • url (a full URL to send the request to)
    • headers (object with string keys & values, replaces all headers if set)
    • body (string or buffer, replaces the body if set)
    • json (object, to be sent as a JSON-encoded body, taking precedence over body if both are set)
    • response (a response callback result, either a response object or 'close', if provided this will be used as an immediately response, the request will not be passed through at all, and any beforeResponse callback will never fire)

    Parameters

    Returns MaybePromise<void | CallbackRequestResult>

  • A callback that will be passed the full response before it is passed through, and which returns a value that defines how the the response content should be transformed before it's returned to the client.

    The callback can either return an object to define how the response should be changed, or the string 'close' to immediately close the underlying connection.

    All fields on the object are optional, and returning undefined is equivalent to returning an empty object (transforming nothing). The possible fields are:

    • status (number, will replace the HTTP status code)
    • headers (object with string keys & values, replaces all headers if set)
    • body (string or buffer, replaces the body if set)
    • json (object, to be sent as a JSON-encoded body, taking precedence over body if both are set)

    Parameters

    Returns MaybePromise<void | CallbackResponseResult>

Generated using TypeDoc