Solutions to the critical Klein–Gordon–Maxwell system with external potential