Registry / http-networking / grunt-middleware-proxy

grunt-middleware-proxy

JSON →
library1.0.7jsnpmunverified

grunt-middleware-proxy is a Grunt plugin that provides an HTTP/HTTPS proxy middleware for grunt-contrib-connect. It supports basic proxy, proxy over proxy, and proxy tunneling. Version 1.0.7 is the current stable release. The package has low maintenance (last commit 2020). It differs from alternatives by being tightly integrated with Grunt's connect task, allowing easy proxy configuration via the 'proxies' option. It uses the 'http-proxy' library under the hood but abstracts away details.

npm install grunt-middleware-proxy
INSTALL
IMPORT
SIG · GRUNT-MIDDLEWARE-P
G
grunt-middleware-proxy
http-networkingjavascriptv1.0.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getProxyMiddleware
var getProxyMiddleware = require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware;
var getProxyMiddleware = require('grunt-middleware-proxy').getProxyMiddleware;
The main export is not a function; you must require the 'Utils' submodule and call getProxyMiddleware().
ProxyMiddleware (default import)
import { getProxyMiddleware } from 'grunt-middleware-proxy/lib/Utils';
import proxyMiddleware from 'grunt-middleware-proxy';
This package does not have a default export; use named import from the Utils path.
grunt.loadNpmTasks
grunt.loadNpmTasks('grunt-middleware-proxy');
require('grunt-middleware-proxy');
In Gruntfile, use loadNpmTasks to register the plugin, not require directly (though require is used inside middleware function).

Shows minimal Gruntfile setup with grunt-contrib-connect and middleware proxy, including proxies configuration.

// Install // npm install grunt-middleware-proxy --save-dev // Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-middleware-proxy'); grunt.initConfig({ connect: { server: { options: { port: 9000, hostname: 'localhost', middleware: function(connect, options, middlewares) { var getProxyMiddleware = require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware; middlewares.unshift(getProxyMiddleware()); return middlewares; } }, proxies: [ { context: '/api', host: 'example.com', port: 8080, https: false, rewriteHost: true } ] } } }); grunt.registerTask('default', ['connect:server']); };
Debug
Known issues
deprecatedThe package is in maintenance mode; last commit in 2020 and no recent updates. Consider using modern alternatives like http-proxy-middleware with express.
fix
Migrate to http-proxy-middleware or a similar actively maintained proxy middleware.
affects: >=1.0.0
breakingThe import path changed between versions: prior to 1.0.0, the module was at 'grunt-middleware-proxy' directly. In 1.0.0+, you must use 'grunt-middleware-proxy/lib/Utils'.
fix
Update your require/import to 'grunt-middleware-proxy/lib/Utils' and call .getProxyMiddleware().
affects: >=1.0.0
gotchaThe context path must start with '/' and should not end with '/'. Omitting these can cause unexpected routing behavior.
fix
Ensure context is e.g., '/api', not 'api' or '/api/'.
affects: >=0.1.0
gotchaThe host option must not include 'http://' or 'https://', just the domain. Including scheme will cause errors.
fix
Use host: 'example.com', not host: 'https://example.com'.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: grunt-middleware-proxy is not a function
Requiring the main package directly instead of the Utils submodule.
fix
Change require('grunt-middleware-proxy') to require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware()
Error: connect.multipart() is not a function
Incompatibility with newer versions of grunt-contrib-connect where the middleware API changed.
fix
Ensure you are using a compatible version of grunt-contrib-connect (e.g., ^0.11.0).
Error: listen EADDRINUSE :::9000
Port conflict; usually another process is using the same port.
fix
Change the port in connect options or kill the process using the port.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
grunt-contrib-connectrequiredThis plugin is middleware for grunt-contrib-connect; it must be installed and configured alongside it.
http-proxyrequiredUsed internally for proxying HTTP/HTTPS requests.
Agent activity
4 hits · last 30 days
node
4
Resources
grunt-middleware-proxy — npm install grunt-middleware-proxy · libregistry