javascript - Converting Image URL to base64 - CORS issue -


i'm trying embed images pdf using pdfmake. this, need use datauris images.

this.getdatauri = (url) => {   var defer = $q.defer();    var image = new image();   image.setattribute('crossorigin', '');   image.src = url;    image.onload = function() {     var canvas = document.createelement('canvas');     canvas.width = this.naturalwidth;     canvas.height = this.naturalheight;      canvas.getcontext('2d').drawimage(this, 0, 0);     defer.resolve(canvas.todataurl('image/png'));   };    image.onerror = function() {     defer.reject();   };    return defer.promise; } 

i have function convert image url need, , working fine until recently, i'm getting error:

image origin 'https://bucketeer-....s3.amazonaws.com' has been blocked loading cross-origin resource sharing policy: no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:3000' therefore not allowed access.

here's cors settings s3 bucket:

{   "corsrules": [     {       "allowedheaders": [         "*"       ],       "allowedmethods": [         "head",         "get",         "put",         "post"       ],       "allowedorigins": [         "*"       ]     }   ] } 

is there can resolve this?


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -