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
Michael Kolodner 13Michael Kolodner 13 

Get the base URL directly in a client side LEX Component controller?

Is there any way to put code directly into the client side controller for a Lightning Component (the .js file) to grab the base URL for my Salesforce instance? I have an idea that it's pretty simple using a server side class. But I am wondering if it can be done without that server side Apex class.
Raj VakatiRaj Vakati
You can try with JS code 
 
console.log('--'+window.location.href);
        console.log('--'+window.location.protocol+'//'+window.location.host  );
        let urltemp =window.location.protocol+'//'+window.location.host ;
       urltemp = urltemp.replace(".lightning.force.com",".my.salesforce.com");
        console.log('--->'+urltemp);