Accessing original host name after rewrite

Hi,

I’ve a web service on my-server.onrender.com. A static site can be accessed using wildcard domain *.example.com pointing to my-ui.onrender.com. In the static site, I’ve written a rewrite rule sending requests to /api to my web service under the same context path.

When the user accesses UI using somedomain.example.com, the request is received by the web service with my-server.onrender.com as the x-forwarded-host header instead of somedomain.example.com. Am I doing something wrong? How can I get the original domain (somedomain.example.com) in the web service?

Thanks