Skip to content

http-proxy-middleware

Node.js middleware that forwards HTTP requests from your server to another target, with simple configuration.

Stars
11.1k
Forks
878
Licence
MIT
Language
TypeScript
Last update
5 days ago
Type
Library

What it is

http-proxy-middleware is a Node.js library that plugs into web servers such as Express or Connect and forwards incoming requests to another server, such as a backend API. It is commonly used during development so a frontend app can call an API on a different address without browser cross-origin problems. It is powered by httpxy, a maintained version of http-proxy.

  • Forward /api requests from a frontend dev server to a backend at another address
  • Rewrite URL paths before forwarding, for example removing a prefix
  • Route requests to different targets based on host name or path using the router option
  • Filter which requests get proxied with pathFilter

Great for

  • Node.js developers running an Express, Connect, or Next.js dev server who need to forward /api requests to a backend
  • Teams that want to rewrite paths or route requests to different targets based on host or path
  • Developers who need WebSocket proxying alongside HTTP proxying

Not ideal for

  • People who need a standalone reverse proxy with no Node.js code, since this library must be mounted inside a Node.js server
  • Projects that do not use Node.js, because the package is for the Node.js ecosystem
Step-by-step guide: how to use http-proxy-middlewareInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install as a dev dependency

    npm install --save-dev http-proxy-middleware
  2. 2

    Run it

    • Install the package with npm.
    • Create a server with Express or another supported server.
    • Call createProxyMiddleware with a target URL.
    • Mount the proxy on a path with app.use('/api', proxy) and start the server.
  3. 3

    Get the most out of it

    • Set changeOrigin to true when proxying to name-based virtual hosted sites, as the README recommends.
    • Use pathFilter with glob patterns to limit which requests are proxied.
    • Use pathRewrite to change paths before they reach the target.
    • Use router to send different hosts or paths to different targets.
    • Use the logger option and debugging section to troubleshoot requests.

Downloads

Strengths

  • Works with several Node.js servers, including Express, Connect, Next.js, and Hono according to the README
  • Configuration is done through a single createProxyMiddleware call with documented options
  • Actively maintained with a README that documents options, WebSocket support, and examples

Trade-offs

  • The README is truncated in this analysis, so some details of setup and advanced behavior could not be verified here
  • Requires writing Node.js code; it is not a configurable tool out of the box
  • Current docs cover v4.x only; older versions have separate documentation

How it compares

ProjectStarsTypeLevelUpdatedBest for
http-proxy-middleware (this)11.1kLibraryintermediate5 days agoNode.js developers running an Express, Connect, or Next.js dev server who need to forward /api requests to a backend
apollo-server14kLibraryintermediate5 days agoNode.js developers who want to add a GraphQL API to an existing Express, Koa or Hapi app
echo32.8kLibraryintermediate6 days agoGo developers building REST APIs or backend services
ws22.8kLibrarybeginner5 days agoNode.js developers who need a WebSocket server or a backend WebSocket client
mitmproxy46.6kDev toolintermediate4 days agoDevelopers debugging how an app talks to a backend API
hysteria22.8kAppintermediate10 days agoPeople on networks with heavy packet loss who want a faster proxy connection

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.