How can I make a request coming from inside of a docker container appear to be coming from my local machine?

Browser running in docker container needs to make a POST to a login service running on a test API in our network. The service is very picky about where POST can come from so it’s rejecting the POST because it’s coming from host.docker.internal instead of localhost.company.com.

It’s very unlikely I’d be able to get host.docker.internal added to the whitelist.

The POST will work fine if the browser is running on my local machine but fails when the browser is running inside a container on my local machine.

I’ve tried docker run --add-host='localhost.mycompany.com:127.0.0.1' and docker run --add-host='localhost:127.0.0.1', neither one worked. The latter seems silly; it was kind of a shot in the dark…

Possible further complication: the browser is running in testcafe inside a docker container, so my request will have an headers like 'Origin: http://172.17.0.2:1337' 'Referer: http://172.17.0.2:1337/WBrtZV38p/http://host.docker.internal:3000/app/'

Short of making a proxy of some sort on my local machine, is there a way to make a POST from the docker container appear to be coming from my local machine?

Source: StackOverflow