{"id":22698,"library":"vite-plugin-http2-proxy","title":"vite-plugin-http2-proxy","description":"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.","status":"active","version":"0.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/swandir/vite-plugin-http2-proxy","tags":["javascript","vite-plugin","http2","proxy","typescript"],"install":[{"cmd":"npm install vite-plugin-http2-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-http2-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-http2-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin designed to work with Vite's dev server","package":"vite","optional":false}],"imports":[{"note":"ESM-only since v0.5.0; CommonJS require will fail.","wrong":"const vitePluginHttp2Proxy = require('vite-plugin-http2-proxy')","symbol":"default","correct":"import vitePluginHttp2Proxy from 'vite-plugin-http2-proxy'"},{"note":"The package exports a default function, not a named export.","wrong":"import { vitePluginHttp2Proxy } from 'vite-plugin-http2-proxy'","symbol":"vitePluginHttp2Proxy","correct":"import vitePluginHttp2Proxy from 'vite-plugin-http2-proxy'"},{"note":"TypeScript users should use `import type` for the ProxyOptions type to avoid runtime side effects.","wrong":"import { ProxyOptions } from 'vite-plugin-http2-proxy'","symbol":"type ProxyOptions","correct":"import type { ProxyOptions } from 'vite-plugin-http2-proxy'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport vitePluginHttp2Proxy from 'vite-plugin-http2-proxy';\n\nexport default defineConfig({\n  plugins: [\n    vitePluginHttp2Proxy({\n      '/api': {\n        target: 'https://http2.example.com',\n        changeOrigin: true,\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Shows how to configure the plugin in vite.config.ts to proxy /api requests to an HTTP/2 backend with changeOrigin enabled."},"warnings":[{"fix":"Use dynamic import or switch project to ESM.","message":"ESM-only since v0.5.0; CommonJS `require()` will throw.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Avoid reusing the same path key in both Vite's `server.proxy` and this plugin.","message":"Proxy options are merged with Vite's own proxy configuration; naming conflicts may cause silent failures.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Verify your backend server is configured for HTTP/2 (e.g., h2 or h2c).","message":"HTTP/2 support requires Node.js >=10.0.0 and a target that actually supports HTTP/2.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Remove `session` from proxy configuration; it is now handled internally.","message":"The `session` option was deprecated in v0.4.0 in favor of automatic session management.","severity":"deprecated","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install vite-plugin-http2-proxy --save-dev` and ensure import path is correct.","cause":"Missing package installation or wrong import path.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'vite-plugin-http2-proxy'"},{"fix":"Use `import` or switch to dynamic import: `const plugin = await import('vite-plugin-http2-proxy')`.","cause":"Using CommonJS `require()` with ESM-only package version.","error":"ERR_REQUIRE_ESM: require() of ES Module not supported"},{"fix":"Pass a configuration object to the plugin function, e.g., `vitePluginHttp2Proxy({ '/api': { target: '...' } })`.","cause":"Plugin called without configuration object.","error":"TypeError: Cannot read properties of undefined (reading 'proxy')"},{"fix":"Ensure your target server is up and accepting connections on the specified port.","cause":"Backend server is not running or rejecting connections.","error":"Error: connect ECONNREFUSED"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}