The most common way to handle this would be to have everything use an HTTP 301 redirect.
To have your app itself handle this, you’ll want to modify it so that every request for domainB.com is 301 redirected to domainA.com. You’d likely be able to find information by googling X 301 redirect where X is your framework or application.
If having the application itself process the redirect is cumbersome, you could setup a second app that just runs nginx and provides the redirects. You’d then remove the certificate for domainB.com from the first app, and add it to the second app. The section The return Directive in this nginx blog post describes a method for this and you can find the official docker image for nginx here.