You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@mjackson/fetch-proxy

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mjackson/fetch-proxy

An HTTP proxy for the web Fetch API

0.4.0
latest
Source
npmnpm
Version published
Weekly downloads
2K
17.68%
Maintainers
1
Weekly downloads
 
Created
Source

fetch-proxy

fetch-proxy is an HTTP proxy for the JavaScript Fetch API.

In the context of servers, an HTTP proxy server is a server that forwards all requests it receives to another server and returns the responses it receives. When you think about it this way, a fetch function is like a mini proxy server sitting right there in your code. You send it requests, it goes and talks to some other server, and it gives you back the response it received.

fetch-proxy allows you to easily create fetch functions that act as proxies to "target" servers.

Features

  • Built on the standard JavaScript Fetch API
  • Supports rewriting Set-Cookie headers received from target server
  • Supports X-Forwarded-Proto and X-Forwarded-Host headers
  • Supports custom fetch implementations

Installation

Install from npm:

npm i @mjackson/fetch-proxy

Usage

import { createFetchProxy } from '@mjackson/fetch-proxy';

// Create a proxy that sends all requests through to remix.run
let proxy = createFetchProxy('https://remix.run');

// This fetch handler is probably running as part of your server somewhere...
function handleFetch(request: Request): Promise<Response> {
  return proxy(request);
}

// Test it out by manually throwing a Request at it
let response = await handleFetch(new Request('https://shopify.com'));

let text = await response.text();
let title = text.match(/<title>([^<]+)<\/title>/)[1];
assert(title.includes('Remix'));

License

See LICENSE

Keywords

fetch

FAQs

Package last updated on 11 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts