Skip to content

Replacements for http-proxy

http-proxy has not been maintained since 2020 and has known crashes, memory leaks, and socket issues on modern Node.js versions.

httpxy

httpxy is a maintained fork of http-proxy with critical upstream bug fixes, zero dependencies, and additional helpers such as proxyFetch and proxyUpgrade.

Example:

ts
import httpProxy from 'http-proxy'
import { createProxyServer } from 'httpxy'
import { createServer } from 'node:http'

const proxy = httpProxy.createProxyServer({}) 
const proxy = createProxyServer({}) 

const server = createServer((req, res) => {
  proxy.web(req, res, { target: 'http://localhost:8080' }) 
  proxy.web(req, res, { target: 'http://localhost:8080' }) 
})

server.on('upgrade', (req, socket, head) => {
  proxy.ws(req, socket, head, { target: 'http://localhost:8080' }) 
  proxy.ws(req, socket, { target: 'http://localhost:8080' }, head) 
})

http-proxy-3

http-proxy-3 is a TypeScript rewrite with API compatibility, HTTP/2 support, and production use in Vite, JupyterHub, and CoCalc.

Example:

ts
import httpProxy from 'http-proxy'
import { createProxyServer } from 'http-proxy-3'
import { createServer } from 'node:http'

const proxy = httpProxy.createProxyServer({}) 
const proxy = createProxyServer({}) 

const server = createServer((req, res) => {
  proxy.web(req, res, { target: 'http://localhost:8080' })
})

server.on('upgrade', (req, socket, head) => {
  proxy.ws(req, socket, head, { target: 'http://localhost:8080' }) 
  proxy.ws(req, socket, { target: 'http://localhost:8080' }, head) 
})

Released under the MIT License. (aba2dbd5)