How 22wink/vite-enhanced-proxy works
vite-enhanced-proxy is a development-time Vite proxy plugin. A Vite user configures and registers the plugin; at startup it can load external proxy settings, resolve target routes, and install Vite proxy handlers. Those handlers forward HTTP, SSE, and WebSocket traffic to selected backends, with filtering, rewrites, middleware, and logging. The plugin and logger implementations are sampled; README capabilities such as detailed request/response logging are included, but their exact internal wiring is not fully shown.
Main entry points: plugin.ts Proxy plugin · logger.ts Proxy logger · index.ts Public API · config-loader.ts External config loader
Components 14
Plugin entry
- Public API
index.ts - Proxy plugin
modules/plugin.ts - Options and types
modules/types.ts
Config and routing
- External config loader
modules/config-loader.ts - Target and rewrite selection
modules/plugin.ts
Proxy traffic
- HTTP proxy handling
modules/plugin.ts - SSE proxy handling
modules/plugin.ts - WebSocket proxy handling
modules/plugin.ts - Request middleware and filters
modules/plugin.ts
Logging
- Proxy logger
modules/logger.ts
Other components
- Vite user
- Vite dev server
- Configured backends
- Console
Connections 22
- Vite user → Public API: configures
- Public API → Proxy plugin: creates
- Public API → Options and types: exports types
- Public API → Proxy logger: exports logger
- Proxy plugin → Vite dev server: registers hooks
- Proxy plugin → External config loader: loads config
- External config loader → Proxy plugin: returns config
- Proxy plugin → Target and rewrite selection: resolves targets
- Target and rewrite selection → HTTP proxy handling: configures routes
- Target and rewrite selection → SSE proxy handling: configures routes
- Target and rewrite selection → WebSocket proxy handling: configures routes
- HTTP proxy handling → Configured backends: forwards HTTP
- SSE proxy handling → Configured backends: forwards events
- WebSocket proxy handling → Configured backends: forwards sockets
- HTTP proxy handling → Request middleware and filters: applies filters
- SSE proxy handling → Request middleware and filters: runs middleware
- WebSocket proxy handling → Request middleware and filters: runs middleware
- Proxy plugin → Proxy logger: creates logger
- HTTP proxy handling → Proxy logger: logs traffic
- SSE proxy handling → Proxy logger: logs events
- WebSocket proxy handling → Proxy logger: logs connections
- Proxy logger → Console: writes logs