🌐
HTTP8M+/wkMIT

http-proxy-middleware

http-proxy-middleware is a one-liner Node.js proxy middleware for Express, Connect, and browser-sync, powered by the http-proxy library. It provides a simple wa

Installation

npm
npm install http-proxy-middleware
yarn
yarn add http-proxy-middleware
pnpm
pnpm add http-proxy-middleware

Import

ESM
import { createProxyMiddleware } from 'http-proxy-middleware';

Quick Example

usage
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';

const app = express();
app.use('/api', createProxyMiddleware({
  target: 'http://localhost:5000',
  changeOrigin: true,
}));

About http-proxy-middleware

http-proxy-middleware is a one-liner Node.js proxy middleware for Express, Connect, and browser-sync, powered by the http-proxy library. It provides a simple way to proxy HTTP requests from your Node.js server to another server, commonly used during development to proxy API calls to a backend server to avoid CORS issues, and in production for microservice routing, load balancing, and API gateway patterns. The middleware supports URL rewriting with pathRewrite rules, WebSocket proxying, custom request and response interceptors, header modification, target selection based on request properties, and SSL/TLS configuration for proxying to HTTPS targets. Common use cases include proxying /api requests from a React or Vue development server to a backend API, routing microservice requests based on URL prefixes, and implementing a simple API gateway that distributes requests to different backend services. The middleware handles connection pooling, error recovery, and timeout configuration for reliable proxy operation. It integrates directly with webpack-dev-server and Vite's proxy configuration, making it a foundational tool in modern frontend development workflows.

Quick Facts

Packagehttp-proxy-middleware
CategoryHTTP
Weekly Downloads8M+
LicenseMIT
Installnpm install http-proxy-middleware

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.