【发布时间】:2019-07-28 06:00:37
【问题描述】:
我正在尝试使用 fabric.js 从亚马逊 cloudfront/s3 url 加载背景图片。
fabric.Image.fromURL(imgURL, function(img) {
canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas),
{
scaleX: canvas.width / img.width,
scaleY: canvas.height / img.height
});
}, {crossOrigin: 'anonymous'});
当 crossOrigin 存在时,我得到标准错误
Access to image at '...' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
当我删除 crossOrigin anon.它会加载图像,但它会污染画布,因此我无法使用toDataURL。
【问题讨论】:
标签: javascript amazon-s3 fabricjs amazon-cloudfront