Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ProxyOptions

Interface for the proxy options which allow the user to filter, customize and decorate proxied requests and responses.

Hierarchy

  • {}
    • ProxyOptions

Index

Properties

Optional filterReq

filterReq: (req: any, res: any) => boolean | Promise<boolean>

The filter request option can be used to limit what requests are proxied.

Return false to continue to execute the proxy; return true to skip the proxy for this request.

Type declaration

    • (req: any, res: any): boolean | Promise<boolean>
    • Parameters

      • req: any
      • res: any

      Returns boolean | Promise<boolean>

Optional filterRes

filterRes: (proxyRes: Response, proxyResData: any) => boolean

The filter response option can be used to limit what responses are used from the proxy.

Return false to continue to execute the proxy; return true to skip the proxy for this request.

Type declaration

    • (proxyRes: Response, proxyResData: any): boolean
    • Parameters

      • proxyRes: Response
      • proxyResData: any

      Returns boolean

Optional memoizeUrl

memoizeUrl: boolean

Configure whether the proxy URL should be memoized for subsequent requests.

If you are using the function form of the URL and require it to be executed on every request then this should be set to false.

True by default.

Optional Private memoizedUrl

memoizedUrl: URL

The memoized url set on first request and used internally if memoizeUrl is set to true.

Optional method

method: string

Configure the HTTP method (verb) used for the outbound proxied request. If not provided the current request method is used.

Optional parseReqBody

parseReqBody: boolean

Configure whether the request body should be parsed and used on proxied requests.

True by default.

Optional preserveHostHeader

preserveHostHeader: boolean

Configure whether the "Host" header should be preserved on proxied requests.

Optional proxyErrorHandler

proxyErrorHandler: (err: any, res: any, next: any) => any

Provide a custom error handling for failed proxied requests.

Type declaration

    • (err: any, res: any, next: any): any
    • Parameters

      • err: any
      • res: any
      • next: any

      Returns any

Optional proxyReqInitDecorator

proxyReqInitDecorator: (proxyReqOpts: RequestInit, srcReq: any) => RequestInit | Promise<RequestInit>

Decorate the outbound proxied request initialization options. This configuration will be used within the fetch method internally to make the request to the provided url.

Type declaration

    • (proxyReqOpts: RequestInit, srcReq: any): RequestInit | Promise<RequestInit>
    • Parameters

      • proxyReqOpts: RequestInit
      • srcReq: any

      Returns RequestInit | Promise<RequestInit>

Optional proxyReqUrlDecorator

proxyReqUrlDecorator: (url: URL, req?: any) => URL | Promise<URL>

Decorate the outbound proxied request url.

Type declaration

    • (url: URL, req?: any): URL | Promise<URL>
    • Parameters

      • url: URL
      • Optional req: any

      Returns URL | Promise<URL>

Optional reqAsBuffer

reqAsBuffer: boolean

Configure whether the request body should be sent as a UInt8Array buffer.

Optional reqBodyEncoding

reqBodyEncoding: "utf-8" | null

The request body encoding to use. Only "utf-8" currently supported.

Optional secure

secure: boolean

Configure whether the outbound proxied request should be over HTTPS. This will always override the protocol produced by the provided proxy URL if set to true.

Optional srcResDecorator

srcResDecorator: (srcReq: any, srcRes: any, proxyRes: Response, proxyResData: any) => any

Decorate the inbound response object from the proxied request.

Type declaration

    • (srcReq: any, srcRes: any, proxyRes: Response, proxyResData: any): any
    • Parameters

      • srcReq: any
      • srcRes: any
      • proxyRes: Response
      • proxyResData: any

      Returns any

Optional srcResHeaderDecorator

srcResHeaderDecorator: (headers: Headers, srcReq: any, srcRes: any, proxyReq: Request, proxyRes: Response) => Headers

Decorate the inbound response headers from the proxied request.

Type declaration

    • (headers: Headers, srcReq: any, srcRes: any, proxyReq: Request, proxyRes: Response): Headers
    • Parameters

      • headers: Headers
      • srcReq: any
      • srcRes: any
      • proxyReq: Request
      • proxyRes: Response

      Returns Headers

Optional Private stream

stream: boolean

Optional timeout

timeout: number

Configure a timeout in ms for the outbound proxied request. If not provided the request will never time out.

Generated using TypeDoc