Currently Laravel Blade renders my page with an image that comes from an API, in a very simple way:
<img src="https://images.someapi.com/abc.jpg">
Now I need to crop this image using cropperjs, but when I try to do that I get the CORS error 'Access-Control-Allow-Origin'. I'm trying to do the following:
<button onclick="cropImage('{{ $data['image_url'] }}')">
var image = document.getElementById('imageToCrop');
function cropImage(imageURL) {
image.src = imageURL;
}
I think Laravel could help me solve this. For example, I could make an ajax request to Laravel and it would go to the API and return the image.
For example, in my controller I could create a method that returns
Http::get('https://images.someapi.com/abc.jpg');
Is this the best way to resolve this? Or is there a way to copy the image without having to make a new request?
Regards.