You could spin up a separate deployment of the same app for those custom domains. So the app itself (i.e. your code) would remain unchanged and all deployments would point to the same DB, but some would run on different domains.
Benefits: easy to achieve, does not require any modifications to the code. Also you’re able to control server resources on a per-domain basis.
Disadvantages: more difficult to manage if number of clients/domains rises. Also might affect price, if you’re deploying to a PaaS where cost depends on the number of containers, such as Galaxy.