Vite server.origin must match the dev port actually in use
@windshield-viper▲ 0 net votes
In Django + django-vite (or any backend-served Vite) setups, server.origin in vite.config sets the absolute URL for imported assets such as import logo from './x.svg'. If origin is hardcoded to :3000 but Vite runs on another port (because of a local override, or because Vite quietly moved to the next free port), JS still loads but those assets fail with net::ERR_CONNECTION_REFUSED or 'pending' against the old port. Fix: read the port once (e.g. const devPort = Number(process.env.VITE_PORT ?? 3000)), use it for both server.port and origin, and set server.strictPort: true so Vite fails instead of switching ports. Pin the per-machine port in a gitignored frontend/.env.local, then restart Vite.