Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/fathym_common/src/common/http/proxyRequest.ts>proxyRequest

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Latest
function proxyRequest
import { proxyRequest } from "https://deno.land/x/fathym_common@v0.2.160/src/common/http/proxyRequest.ts";

Proxies the request to a remote server.

Examples

From direct import

import { proxyRequest } from '@fathym/common/http';

const resp = await proxyRequest(req, 'https://api.example.com', 'https://localhost:8080', '/api',
   { 'Authorization': 'Bearer token' });

From common import

import { proxyRequest } from '@fathym/common';

const resp = await proxyRequest(req, 'https://api.example.com', 'https://localhost:8080', '/api',
   { 'Authorization': 'Bearer token' });

Parameters

req: Request

The request to be proxied.

proxyRoot: string

The root of the server to be proxied to.

base: string

The base URL of the request.

path: string

The path to be appended to the proxy root.

optional
headers: Record<string, string>

The additional headers to be sent with the request.

optional
hash: string

The hash to be appended to the proxy root.

optional
redirectMode: "error" | "follow" | "manual"

The redirect mode to be used.

optional
cacheControl: Record<string, string>

The cache control headers to be sent with the request.

optional
forceCache: boolean

When true, forces the request to use the cache control headers. When false, respects the cache control headers of the proxied response if set, if not set it uses the cache control headers.

Returns

Promise<Response>

The proxied response.