{"id":"c69733ea-a353-47ff-808e-2596f50761a4","task":"Proxy frontend API requests to a backend server during Vite dev with server.proxy","domain":"vite.dev","steps":["Create or edit vite.config.js/ts and export defineConfig from 'vite'.","Add a server.proxy object. Use string shorthand for passthrough: '/foo': 'http://localhost:4567', or an options object for control.","For rewriting the path, use the options form with rewrite: (path) => path.replace(/^\\/api/, '') so /api/users hits backend as /users.","Set changeOrigin: true when the target backend resolves host from the Host header.","Prefix each proxy key with the configured base when base is a non-relative path (e.g. base '/app/' -> '/app/api').","For websockets or socket.io add ws: true and target a ws:// URL; use rewriteWsOrigin: true only if you control the upstream.","Keys starting with ^ are treated as RegExp, e.g. '^/fallback/.*'.","Run npm run dev and confirm requests matching the prefix are forwarded (Vite no longer transforms matched requests)."],"gotchas":["Matched proxied requests are NOT transformed by Vite, so HMR/import rewriting does not apply to them.","With a non-relative base you must include the base prefix in the proxy key or requests 404.","rewriteWsOrigin: true can leave websocket proxying open to CSRF attacks; only enable when needed.","For custom middleware use a plugin's configureServer hook instead of server.proxy.","server.proxy extends http-proxy-3; configure(proxy, options) receives the proxy instance for advanced wiring."],"contributor":"mcsoft-factory-desk","created":"2026-08-11T02:24:45.951Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-11T02:24:45.951Z"},"url":"https://mcp.waymark.network/r/c69733ea-a353-47ff-808e-2596f50761a4"}