Registry / http-networking / vite-plugin-proxy

vite-plugin-proxy

JSON →
library0.5.0jsnpmunverified

A Vite plugin that provides webpack-dev-server-style proxy functionality for Vite's dev server, wrapping http-proxy-middleware. Current stable version is 0.5.0. Release cadence is low. Key differentiator: offers a familiar API for webpack users migrating to Vite, with full http-proxy-middleware options support. Note: Vite 2+ includes built-in proxy support via server.proxy, which is the recommended approach; this plugin is primarily for those wanting an explicit plugin or custom HTTP proxy middleware behavior.

npm install vite-plugin-proxy
INSTALL
IMPORT
SIG · VITE-PLUGIN-PROXY
V
vite-plugin-proxy
http-networkingjavascriptv0.5.0
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

vite-plugin-proxy (default)
import proxyPlugin from 'vite-plugin-proxy'
const proxyPlugin = require('vite-plugin-proxy')
ESM recommended since Vite is ESM-first. The package only exports a default export (a factory function). CommonJS require works but may cause issues in some Vite configs.
proxy (named, if re-exported)
import proxyPlugin from 'vite-plugin-proxy'
import { proxy } from 'vite-plugin-proxy'
There is no named export; only a default export. The README shows require, but import is preferred in ESM context.
ProxyOptions (type)
import type { ProxyOptions } from 'vite'
import type { ProxyOptions } from 'vite-plugin-proxy'
Proxy options are defined by Vite's server.proxy, which matches http-proxy-middleware. This plugin does not export its own types. Use Vite's types or http-proxy-middleware types.

Shows a minimal Vite config using vite-plugin-proxy to proxy /api to a remote target with cache headers.

import { defineConfig } from 'vite'; import proxyPlugin from 'vite-plugin-proxy'; export default defineConfig({ plugins: [ proxyPlugin({ '/api': { target: 'https://reqres.in', changeOrigin: true, onProxyRes: (proxyRes) => { proxyRes.headers['Cache-Control'] = `public, max-age=${365 * 24 * 60 * 60}`; delete proxyRes.headers['expires']; }, }, }), ], });
Debug
Known issues
deprecatedVite 2+ has built-in proxy support via server.proxy. Using this plugin is now redundant for most use cases.
fix
Use Vite's built-in proxy: export default defineConfig({ server: { proxy: { '/api': { target: 'http://example.com' } } } });
affects: >=2.0
gotchaPlugin options are passed directly to http-proxy-middleware. Some options may behave differently in Vite's context (e.g., pathRewrite).
fix
Refer to http-proxy-middleware documentation; test thoroughly with your Vite version.
affects: >=0.0
gotchaThe plugin only works during dev server. Not applicable for production builds.
fix
Use environment checks or conditionally apply the plugin only in dev mode: plugins: [process.env.NODE_ENV === 'development' && proxyPlugin(...)].filter(Boolean)
affects: >=0.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-proxy'
Package not installed or incorrect import path.
fix
Install the package: npm install vite-plugin-proxy --save-dev
TypeError: proxyPlugin is not a function
Using default import incorrectly (e.g., import { proxyPlugin } ... instead of import proxyPlugin ...)
fix
Use default import: import proxyPlugin from 'vite-plugin-proxy'
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
http-proxy-middlewarerequiredCore dependency for proxy functionality. All proxy options are passed to http-proxy-middleware.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
vite-plugin-proxy — npm install vite-plugin-proxy · libregistry