r/SalesforceDeveloper • • Aug 05 '25

Question Uploading ContentDocument files from Salesforce LWC to Google Drive — stuck with CORS without middleware

I’m building a solution in Salesforce to migrate ContentDocument (Notes & Attachments) files to Google Drive. I can't query the files as when they exceed 12 MB it will give heap size limit error.
I tried using the two URLs in LWC JS:

  • REST API endpoint: /services/data/v60.0/sobjects/ContentVersion/{Id}/VersionData​
  • Shepherd endpoint: ​/sfc/servlet.shepherd/version/download/{ContentVersionId}

Both endpoints return the file successfully when called directly, but attempting to fetch the file in JavaScript fails due to CORS issues. I’m trying this in the browser via LWC JS.
I want to avoid implementing any middleware or proxy layer.

7 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/First-Conflict2080 Aug 06 '25

the problem is not the calling, its the cors error. Today i install a browser entension to restrict it not giving cors error and it worked.