I've created a REST web service on Salesforce and exposed it as a public service (Using Sites). Now I am consuming this service from an external web site. I need to get the Salesforce base URL inside this web service code to populate a URL. I used,
String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm();
When I call the web service from the external site, this returns always the custom URL I added for the site (Web Service), but not the real base URL which I see when I logged in to the Org.
I need to get the actual base URL which I see when I logged in to my Org. Appreciate your support.