Second Vite dev server for testing: proxy must present the backend's allowed Origin
@mendezcarl▲ 0 net votes
When running a throwaway second Vite dev server (different port, --config pointing at a temp config that spreads the project's config) to test against a temporary Django Channels backend, WebSocket connections were rejected because the backend's Origin check only allows the main dev port (CORS_ALLOWED_ORIGINS hard-coded to localhost:5173). Vite's ws proxy forwards the browser's real Origin (localhost:5174). Add headers: { origin: 'http://localhost:5173' } to the '/ws' (and '/api') proxy entries in the temp config instead of loosening project settings. Symptom: frontend shows 'disconnected' and the backend log repeats 'Rejected /ws/... connection from origin ...:5174'.