
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
@types/http-proxy-middleware
Advanced tools
Stub TypeScript definitions entry for http-proxy-middleware, which provides its own types definitions
@types/http-proxy-middleware provides TypeScript type definitions for the http-proxy-middleware package, which is used to create a proxy middleware for connecting, redirecting, and modifying HTTP requests in a Node.js application.
Basic Proxy Setup
This feature allows you to set up a basic proxy middleware that forwards requests from '/api' to 'http://www.example.org'. The 'changeOrigin' option modifies the origin of the host header to the target URL.
const { createProxyMiddleware } = require('http-proxy-middleware');
const apiProxy = createProxyMiddleware('/api', { target: 'http://www.example.org', changeOrigin: true });
module.exports = function(app) {
app.use(apiProxy);
};
Path Rewriting
This feature allows you to rewrite the URL path before forwarding the request. In this example, requests to '/api' will be forwarded to 'http://www.example.org' with the '/api' prefix removed.
const { createProxyMiddleware } = require('http-proxy-middleware');
const apiProxy = createProxyMiddleware('/api', {
target: 'http://www.example.org',
pathRewrite: { '^/api': '' },
changeOrigin: true
});
module.exports = function(app) {
app.use(apiProxy);
};
Custom Proxy Configuration
This feature allows you to customize the proxy request by adding custom headers or modifying the request in other ways. In this example, a custom header 'X-Special-Proxy-Header' is added to the proxied request.
const { createProxyMiddleware } = require('http-proxy-middleware');
const apiProxy = createProxyMiddleware('/api', {
target: 'http://www.example.org',
changeOrigin: true,
onProxyReq: (proxyReq, req, res) => {
// Add custom header to request
proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');
}
});
module.exports = function(app) {
app.use(apiProxy);
};
http-proxy is a library for creating HTTP proxies in Node.js. It provides a lower-level API compared to http-proxy-middleware, giving you more control over the proxying process but requiring more setup and configuration.
express-http-proxy is a simpler alternative to http-proxy-middleware for proxying HTTP requests in an Express application. It offers a more straightforward API but with fewer customization options compared to http-proxy-middleware.
node-http-proxy is another library for creating HTTP proxies in Node.js. It is similar to http-proxy but offers additional features like WebSocket proxying and more detailed event handling.
This is a stub types definition for @types/http-proxy-middleware (https://github.com/chimurai/http-proxy-middleware#readme).
http-proxy-middleware provides its own type definitions, so you don't need @types/http-proxy-middleware installed!
FAQs
Stub TypeScript definitions entry for http-proxy-middleware, which provides its own types definitions
The npm package @types/http-proxy-middleware receives a total of 192,949 weekly downloads. As such, @types/http-proxy-middleware popularity was classified as popular.
We found that @types/http-proxy-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.