{"id":18402,"library":"grunt-middleware-proxy","title":"grunt-middleware-proxy","description":"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.","status":"maintenance","version":"1.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/frankrafael/grunt-middleware-proxy","tags":["javascript","gruntplugin"],"install":[{"cmd":"npm install grunt-middleware-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add grunt-middleware-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add grunt-middleware-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This plugin is middleware for grunt-contrib-connect; it must be installed and configured alongside it.","package":"grunt-contrib-connect","optional":false},{"reason":"Used internally for proxying HTTP/HTTPS requests.","package":"http-proxy","optional":false}],"imports":[{"note":"The main export is not a function; you must require the 'Utils' submodule and call getProxyMiddleware().","wrong":"var getProxyMiddleware = require('grunt-middleware-proxy').getProxyMiddleware;","symbol":"getProxyMiddleware","correct":"var getProxyMiddleware = require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware;"},{"note":"This package does not have a default export; use named import from the Utils path.","wrong":"import proxyMiddleware from 'grunt-middleware-proxy';","symbol":"ProxyMiddleware (default import)","correct":"import { getProxyMiddleware } from 'grunt-middleware-proxy/lib/Utils';"},{"note":"In Gruntfile, use loadNpmTasks to register the plugin, not require directly (though require is used inside middleware function).","wrong":"require('grunt-middleware-proxy');","symbol":"grunt.loadNpmTasks","correct":"grunt.loadNpmTasks('grunt-middleware-proxy');"}],"quickstart":{"code":"// Install\n// npm install grunt-middleware-proxy --save-dev\n\n// Gruntfile.js\nmodule.exports = function(grunt) {\n  grunt.loadNpmTasks('grunt-middleware-proxy');\n\n  grunt.initConfig({\n    connect: {\n      server: {\n        options: {\n          port: 9000,\n          hostname: 'localhost',\n          middleware: function(connect, options, middlewares) {\n            var getProxyMiddleware = require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware;\n            middlewares.unshift(getProxyMiddleware());\n            return middlewares;\n          }\n        },\n        proxies: [\n          {\n            context: '/api',\n            host: 'example.com',\n            port: 8080,\n            https: false,\n            rewriteHost: true\n          }\n        ]\n      }\n    }\n  });\n\n  grunt.registerTask('default', ['connect:server']);\n};","lang":"javascript","description":"Shows minimal Gruntfile setup with grunt-contrib-connect and middleware proxy, including proxies configuration."},"warnings":[{"fix":"Migrate to http-proxy-middleware or a similar actively maintained proxy middleware.","message":"The package is in maintenance mode; last commit in 2020 and no recent updates. Consider using modern alternatives like http-proxy-middleware with express.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Update your require/import to 'grunt-middleware-proxy/lib/Utils' and call .getProxyMiddleware().","message":"The 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'.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure context is e.g., '/api', not 'api' or '/api/'.","message":"The context path must start with '/' and should not end with '/'. Omitting these can cause unexpected routing behavior.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use host: 'example.com', not host: 'https://example.com'.","message":"The host option must not include 'http://' or 'https://', just the domain. Including scheme will cause errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change require('grunt-middleware-proxy') to require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware()","cause":"Requiring the main package directly instead of the Utils submodule.","error":"TypeError: grunt-middleware-proxy is not a function"},{"fix":"Ensure you are using a compatible version of grunt-contrib-connect (e.g., ^0.11.0).","cause":"Incompatibility with newer versions of grunt-contrib-connect where the middleware API changed.","error":"Error: connect.multipart() is not a function"},{"fix":"Change the port in connect options or kill the process using the port.","cause":"Port conflict; usually another process is using the same port.","error":"Error: listen EADDRINUSE :::9000"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}