Registry / http-networking / vite-plugin-http2-proxy

vite-plugin-http2-proxy

JSON →
library0.5.1jsnpmunverified

A Vite plugin that enables HTTP/2 proxy support for development servers. Current stable version v0.5.1 supports Vite 2 through 7 with TypeScript types. It wraps the underlying http-proxy and provides HTTP/2 connectivity, which is not natively supported by Vite's built-in proxy. Unlike Vite's default http-proxy configuration, this plugin handles the `http2` session negotiation transparently. Released occasionally with focus on compatibility across major Vite versions.

npm install vite-plugin-http2-proxy
INSTALL
IMPORT
SIG · VITE-PLUGIN-HTTP2-
V
vite-plugin-http2-proxy
http-networkingjavascriptv0.5.1
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 vitePluginHttp2Proxy from 'vite-plugin-http2-proxy'
const vitePluginHttp2Proxy = require('vite-plugin-http2-proxy')
ESM-only since v0.5.0; CommonJS require will fail.
vitePluginHttp2Proxy
import vitePluginHttp2Proxy from 'vite-plugin-http2-proxy'
import { vitePluginHttp2Proxy } from 'vite-plugin-http2-proxy'
The package exports a default function, not a named export.
type ProxyOptions
import type { ProxyOptions } from 'vite-plugin-http2-proxy'
import { ProxyOptions } from 'vite-plugin-http2-proxy'
TypeScript users should use `import type` for the ProxyOptions type to avoid runtime side effects.

Shows how to configure the plugin in vite.config.ts to proxy /api requests to an HTTP/2 backend with changeOrigin enabled.

import { defineConfig } from 'vite'; import vitePluginHttp2Proxy from 'vite-plugin-http2-proxy'; export default defineConfig({ plugins: [ vitePluginHttp2Proxy({ '/api': { target: 'https://http2.example.com', changeOrigin: true, }, }), ], });
Debug
Known issues
breakingESM-only since v0.5.0; CommonJS `require()` will throw.
fix
Use dynamic import or switch project to ESM.
affects: >=0.5.0
gotchaProxy options are merged with Vite's own proxy configuration; naming conflicts may cause silent failures.
fix
Avoid reusing the same path key in both Vite's `server.proxy` and this plugin.
affects: >=0.1.0
gotchaHTTP/2 support requires Node.js >=10.0.0 and a target that actually supports HTTP/2.
fix
Verify your backend server is configured for HTTP/2 (e.g., h2 or h2c).
affects: >=0.1.0
deprecatedThe `session` option was deprecated in v0.4.0 in favor of automatic session management.
fix
Remove `session` from proxy configuration; it is now handled internally.
affects: >=0.4.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'vite-plugin-http2-proxy'
Missing package installation or wrong import path.
fix
Run `npm install vite-plugin-http2-proxy --save-dev` and ensure import path is correct.
ERR_REQUIRE_ESM: require() of ES Module not supported
Using CommonJS `require()` with ESM-only package version.
fix
Use `import` or switch to dynamic import: `const plugin = await import('vite-plugin-http2-proxy')`.
TypeError: Cannot read properties of undefined (reading 'proxy')
Plugin called without configuration object.
fix
Pass a configuration object to the plugin function, e.g., `vitePluginHttp2Proxy({ '/api': { target: '...' } })`.
Error: connect ECONNREFUSED
Backend server is not running or rejecting connections.
fix
Ensure your target server is up and accepting connections on the specified port.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
viterequiredpeer dependency; plugin designed to work with Vite's dev server
Agent activity
21 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
vite-plugin-http2-proxy — npm install vite-plugin-http2-proxy · libregistry