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

Cross-origin image load denied by Cross-Origin Resource Sharing policy.

	function postImage(imageURL){
		var image = document.createElement('img');
	        var canvas = document.createElement('canvas');
		image.onload = function(e){
		  	console.log('Attempting image post');		  	

		    canvas.width = image.width;
		    canvas.height = image.height;		  
		    var ctx = canvas.getContext("2d");
		    ctx.drawImage(image, 0, 0);		  	
		    var dataURL = canvas.toDataURL("image/png");		
		    dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
		    console.log('length of image blob: ' + dataURL.length);
		        if(event.type == 'exception'){
		            console.log('Error pinning image: ' + event.message);
		        	console.log('Successful image pin');
		image.crossOrigin = 'anonymous';

Within visualforce, the above javascript results in the error "Cross-origin image load denied by Cross-Origin Resource Sharing policy." when fed an image url for an external domain, even though I'm setting the crossOrigin attribute to anonymous. Does Salesforce have any special CORS restrictions?