Registry / devops / vite-plugin-proxy-middleware

vite-plugin-proxy-middleware

JSON →
library1.0.2jsnpmunverified

A Vite plugin that resolves the conflict between using HTTP/2 (h2) and Vite's built-in proxy. When HTTPS is enabled for HTTP/2, Vite's proxy configuration becomes incompatible. This plugin provides a separate proxy table configuration via a file path or object, enabling both HTTP/2 and proxy to work simultaneously. v1.0.2 is stable. Requires Vite with HTTPS enabled. Alternative to manually working around the conflict.

npm install vite-plugin-proxy-middleware
INSTALL
IMPORT
SIG · VITE-PLUGIN-PROXY-
V
vite-plugin-proxy-middleware
devopsjavascriptv1.0.2
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.

default
import VitePluginProxyMiddleware from 'vite-plugin-proxy-middleware'
const VitePluginProxyMiddleware = require('vite-plugin-proxy-middleware')
ESM default export. CommonJS require not supported.
VitePluginProxyMiddleware
import VitePluginProxyMiddleware from 'vite-plugin-proxy-middleware'
import { VitePluginProxyMiddleware } from 'vite-plugin-proxy-middleware'
Not a named export; use default import.

Shows basic configuration with proxy table object, HTTPS setup for HTTP/2, and note to avoid Vite's native proxy option.

// vite.config.ts import { defineConfig } from 'vite' import VitePluginProxyMiddleware from 'vite-plugin-proxy-middleware' export default defineConfig({ plugins: [ VitePluginProxyMiddleware({ proxyTable: { '/api': { target: 'https://api.example.com', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') } }, mockPath: '/dev-mock' }) ], server: { https: { key: './localhost-key.pem', cert: './localhost.pem' } // Do NOT use Vite's proxy here } })
Debug
Known issues
gotchaVite's built-in proxy must be disabled (do not set server.proxy) when using this plugin.
fix
Remove server.proxy from vite.config; use plugin's proxyTable instead.
affects: >=1.0.0
gotchaHTTPS must be enabled for HTTP/2 to work; plugin requires server.https configuration.
fix
Generate SSL certificates and set server.https in vite.config.
affects: >=1.0.0
gotchaproxyTable option can be a path string (e.g., './proxy-table') but the file must export an object with environment keys (dev, test, gray, prod).
fix
Ensure proxy-table.js/ts exports an object like { dev: { ... }, prod: { ... } }.
affects: >=1.0.0
gotchaThe plugin uses http-proxy-middleware internally, but with a slightly different API; rewrite function must be defined on each rule.
fix
Include rewrite in proxy rule: { target: '...', rewrite: (path) => path.replace(/^\/api/, '') }
affects: >=1.0.0
Errors
Common errors & fixes
Error: The 'proxyTable' option is required.
Missing proxyTable option in plugin configuration.
fix
Add proxyTable: { ... } or proxyTable: './path/to/proxy-table' to VitePluginProxyMiddleware options.
Error: Cannot find module './proxy-table'
When proxyTable is a file path, the file does not exist or is not accessible.
fix
Ensure the proxy table file exists at the specified path and exports an object.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
viterequiredVite plugin, requires Vite as peer dependency
Agent activity
22 hits · last 30 days
node
16
OpenAI (training)
4
Resources
vite-plugin-proxy-middleware — npm install vite-plugin-proxy-middleware · libregistry