-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORS error when loading images from external urls #319
Comments
Could u please provide more context about ur issue to be able to check? as it is fixed |
I don't really have any other context. I just get a cors error when trying to use an outside url on a production env. It seems like it works locally but when running on https://example.com, it fails with cors. Apparently others are having the same problem. |
I'm sorry I couldn't provide any help for an issue not clear for me,,, some more context about the issue would be more helpful ex. The url used, video/steps/codesandbox producing the issue |
@jbwestphal I have wrote down ur image's url and copied into the demo and it works good without any errors, could u please clarify? |
Its a problem on production. Not local which is strange |
I see, yeah it's weird because it happens sometimes... The URL is from AWS S3 Bucket, which is set as public... wondering if we need to take extra steps to make sure the plugin always accepts any image URL. We are using the ReactJs version, e.g. "react-filerobot-image-editor": "^4.4.0" <FilerobotImageEditor
source={source} // which is always this kind of AWS URL
onSave={(editedImageObject, designState) => {
...
}}
closeAfterSave
onClose={close}
Rotate={{ angle: 90, componentType: 'slider' }}
Crop={{
ratio: 1 / 1,
ratioTitleKey: 'Square',
noPresets: true,
}}
tabsIds={[TABS.ADJUST, TABS.RESIZE, TABS.FILTERS, TABS.FINETUNE]}
/> |
@Wamy-Dev Checked the same image of @jbwestphal on demo's hosted prod. and still working fine! @jbwestphal we don't face such an issue in fact so it's always accepting any image URL, I'm getting surprised that both of u face the issue... but from plugin's side it's as expected the thing u could do from ur side checking ur server and make sure it has (Access-Control-Allow-Origin headers allow shared requests) -- CORS enabled -- and anyways I'd be happy if u could provide more context to debug the issue |
@AhmeeedMostafa I am trying to debug this issue with @jbwestphal. The external URL always loads just fine in the browser inline (even when the CORS error appears). The issue is only triggered when activating the firebot plugin. Are you loading the image in a non-standard way that would confuse the browser? This is what our CORS policy is on the S3 bucket:
Are there any other methods you would use besides GET and HEAD? |
@drlube nope, if any of u could provide a codesandbox contains the code that generates the CORS error I might help otherwise I couldn't really help as still no clear info for me.... the mentioned CORS policy seems good so not pretty sure what causing the issue |
Hello guys, I've had the same problem, I use the AWS CloudFront CDN paired with a Lambda function to serve my images and assets and I have two solutions to resolve these CORS errors:
For the first option you can do somthing like this: /**
* @param {String} src URL of the remote image or base64.
* @returns {String}
*/
const loadImage = (src) => {
const image = new Image();
image.onload = () => console.log(image);
image.crossOrigin = 'Anonymous';
image.src = src;
return image.src;
}; Remove the |
Loading the image into an img tag and then getting the data from that is what I have had to resort to as it was simple enough to do. This needs to be fixed though. |
@Wamy-Dev if we removed |
@ALL, we have supported |
This seems to fix our issue for now: https://www.hacksoft.io/blog/handle-images-cors-error-in-chrome It's because the cached image loaded via the |
Closed as it's pretty clear for all of us now. |
If I use noCrossOrigin then the image is loaded but I get this error. |
cdfd80c
Supposedly fixed on this commit ^^^
using:
"react-filerobot-image-editor": "^4.3.8"
Any fixes?
The text was updated successfully, but these errors were encountered: