How to tell which domain is used to access a service

Hi!

I have a service that’s currently using the render subdomain, and I want to switch to a custom domain. My service needs to know the domain in order to generate callback URLs, for example for OAuth. I’m currently just using an environment variable that specifies the domain name (currently <whatever>.onrender.com).

After adding the custom domain, how can I tell which domain the users are using to access the service? I’d like to detect when the onrender domain is used and redirect to the new domain, or at least generate callback URLs correctly (matching the current domain used).

Hi,

That will depend on which language/framework you’re using. Search Google for something like “ get hostname” or similar.

Hi, thanks for the reply!

I don’t see how that is possible on the server, as it’s sitting behind a reverse proxy, so it doesn’t know of the outside world. Also I need to know this at a request level.
Now that I think of it, I think what I’m looking for is X-Forwarded-Host. Is there any documentation on what reverse proxy Render is using and what headers it sets?

Just the Host header would work to get the requesting domain.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.