function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surendra nuneSurendra nune 

Acess URL.getSalesforceBaseUrl().toExternalForm() from execute anonymous


I need to set the CORS headers to an external system from Salesforce using http callouts.

To get the current request URL I know that we use,

But I need the url of visualforce page and Site in an apex controller which is not associated to any vf page for setting the cors headers. 
How can I acheive this?

NagaNaga (Salesforce Developers) 
Hi Surendra,

CORS loosens the browser Same Origin policy in a controlled manner, allowing JavaScript loaded from one origin, for example,, to access an API in another, for example,, by allowing the API server to provide a list of origins that may be permitted access.

Please follow the below link for more information

Best Regards
Naga kiran