No 'Access-Control-Allow-Origin' header is present on the requested resource?
Carrie999 opened this issue · comments
How do we solve this issue
I keep getting blocked by cors error
This is unrelated to exif-js as far as I can tell. You have to provide more context of your problem for anybody to help you.
CORS is not an error, it is a feature ;) (to prevent things like DDOS attacks from front-end code).
Are you trying to get exif information from a picture that is on another domain? By providing an absolute URL to an image? You have to have a picture locally, or retrieve the picture through back-end code first (useing exif in NodeJS?), because the back-end does not enfore CORS policy. But browsers do... You can install an extension in your browser that circumvents CORS, but that is not a solution you should require/force of users of your front-end.
CORS issues in principle have to do with back-end code or back-end configuration. Please investigate this more. You can solve it two ways:
- You have to provide the .js files (wether you use exif-js in there or not) for front-end code from the same domain as where your endpoints are that you use for AJAX requests. That way this falls under SAME ORIGING policy instead of CROSS ORIGIN
- Enable CORS (Cross Origin Resource Sharing) by returning the correct Acces-Control-Allow-Origing http headers on OPTIONS requests, that the browsers sends to conform to the CORS policy. For either all your end points (hacky) or specific endpoints that cause this error. This is often - more conveniently - done by installing a CORS plugin, that handles this for you. This depends on your back-end technology (Java/JEE, or NodeJS or .NET or whatever).
From what I understand, if you're hosting images on S3, they need withCredentials = true
set on the XMLHttpRequests, otherwise the CORS policy won't be returned. @Kuchitama's pull request fixed it for me #187