I want to call Salesforce REST APIs (to the same salesforce org where lightning component is built) from client side JS code in Aura/LWC. I have done some research and thought of this approach.
- Add Salesforce org URL to the CSP trusted settings and CORS.
- get api enabled session Id from apex using one of this approach
- pass the api enabled session id using aura enabled apex method to LWC/Aura JS code.
- Use the session id received in step 2 to call Salesforce APIs.
I am not sure if this approach will work or will I get CSP or CORS error even though I have added the salesforce org url to the CORS settings.
This lightning component will only be used by internal employees. I think the security concern of the session id being passed from apex to client side JS code being visible in browser tools shouldn't concern us. Do you think otherwise or does it pose an other security concerns?
The user selects more 1 or more files and add details related to each file. The lightning component then validates the details entered for each file by calling apex controller. it displays the validation result and then gives option to proceed with upload of these files and related details.
I can not use lightning-file-upload component (2GB file size) because it will upload the file as soon as user selects it.
If i use input type = file element it is limited with file size of approx 4 MB. So, I came up with this approach to call rest api to upload files after validation without calling apex.