Skip to main content
Module

x/opineHttpProxy/mod.ts>ProxyOptions

Proxy middleware for Deno Opine HTTP servers.
Latest
interface ProxyOptions
implements Omit<RequestInit, "body" | "window" | "method">
import { type ProxyOptions } from "https://deno.land/x/opineHttpProxy@3.2.0/mod.ts";

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

Properties

optional
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.

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

Provide a custom error handling for failed proxied requests.

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

Decorate the outbound proxied request url.

optional
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.

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

Decorate the inbound response headers from the proxied request.

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

Decorate the inbound response object from the proxied request.

optional
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.

optional
preserveHostHeader: boolean

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

optional
parseReqBody: boolean

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

True by default.

optional
reqBodyEncoding: "utf-8" | null

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

optional
reqAsBuffer: boolean

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

optional
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
memoizedUrl: URL

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

optional
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
timeout: number

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

optional
method: string

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

optional
stream: boolean