{"id":22790,"library":"vite-plugin-proxy","title":"vite-plugin-proxy","description":"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.","status":"active","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/zigomir/vite-plugin-proxy","tags":["javascript","vite","vue","proxy"],"install":[{"cmd":"npm install vite-plugin-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for proxy functionality. All proxy options are passed to http-proxy-middleware.","package":"http-proxy-middleware","optional":false}],"imports":[{"note":"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.","wrong":"const proxyPlugin = require('vite-plugin-proxy')","symbol":"vite-plugin-proxy (default)","correct":"import proxyPlugin from 'vite-plugin-proxy'"},{"note":"There is no named export; only a default export. The README shows require, but import is preferred in ESM context.","wrong":"import { proxy } from 'vite-plugin-proxy'","symbol":"proxy (named, if re-exported)","correct":"import proxyPlugin from 'vite-plugin-proxy'"},{"note":"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.","wrong":"import type { ProxyOptions } from 'vite-plugin-proxy'","symbol":"ProxyOptions (type)","correct":"import type { ProxyOptions } from 'vite'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport proxyPlugin from 'vite-plugin-proxy';\n\nexport default defineConfig({\n  plugins: [\n    proxyPlugin({\n      '/api': {\n        target: 'https://reqres.in',\n        changeOrigin: true,\n        onProxyRes: (proxyRes) => {\n          proxyRes.headers['Cache-Control'] = `public, max-age=${365 * 24 * 60 * 60}`;\n          delete proxyRes.headers['expires'];\n        },\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Shows a minimal Vite config using vite-plugin-proxy to proxy /api to a remote target with cache headers."},"warnings":[{"fix":"Use Vite's built-in proxy: export default defineConfig({ server: { proxy: { '/api': { target: 'http://example.com' } } } });","message":"Vite 2+ has built-in proxy support via server.proxy. Using this plugin is now redundant for most use cases.","severity":"deprecated","affected_versions":">=2.0"},{"fix":"Refer to http-proxy-middleware documentation; test thoroughly with your Vite version.","message":"Plugin options are passed directly to http-proxy-middleware. Some options may behave differently in Vite's context (e.g., pathRewrite).","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Use environment checks or conditionally apply the plugin only in dev mode: plugins: [process.env.NODE_ENV === 'development' && proxyPlugin(...)].filter(Boolean)","message":"The plugin only works during dev server. Not applicable for production builds.","severity":"gotcha","affected_versions":">=0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package: npm install vite-plugin-proxy --save-dev","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'vite-plugin-proxy'"},{"fix":"Use default import: import proxyPlugin from 'vite-plugin-proxy'","cause":"Using default import incorrectly (e.g., import { proxyPlugin } ... instead of import proxyPlugin ...)","error":"TypeError: proxyPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}