Few issues with importing images from AWS S3 bucket onto JSPDF autotable

148 Views Asked by At

I've been trying to import images stored in my AWS S3 bucket onto a pdf with the help of jspdf autotable. Here's a stackblitz showing how I'd like the code to run. Now while I'm getting desired output from on stackblitz, when I try the same on my Angular 8 project, I get the following error:

zone-evergreen.js:2981 Access to XMLHttpRequest at 'https://url/image.png' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Which is odd since I set the following CORS Policy in my S3 bucket permissions:

[
    {
        "AllowedHeaders": [
            "Authorization",
            "Content-Range",
            "Accept",
            "Content-Type",
            "Origin",
            "Range"
        ],
        "AllowedMethods": [
            "HEAD",
            "GET",
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "ETag"
        ],
        "MaxAgeSeconds": 3000
    }
]

Could it be a security issue, with unsecured sites being unable to access the images and display them in the autotable in jspdf, while it's possible for stackblitz to do so? What changes do I need to make in my S3 bucket policy to allow this?

0

There are 0 best solutions below