Error when trying to upload image by link
mpanius opened this issue · comments
When trying to upload image by url i get an error
Access to fetch at 'https://www.ixbt.com/img/x780/n1/news/2023/1/2/3.png' from origin 'https://video.test' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Is it downside of using fetch() in js for geting file content? Or some error in CORS in my application?
Cause getting same file by url works fine in this integration with livewire https://github.com/maxeckel/livewire-editorjs
It is using serverside loadImageFromUrl
public function loadImageFromUrl(string $url)
{
$name = basename($url);
$content = file_get_contents($url);
Storage::disk($this->downloadDisk)->put($name, $content);
return Storage::disk($this->downloadDisk)->url($name);
}
I also tried to use CORS proxy (cors.sh - first found).
In this case i get error
Undefined array key "name" in file /Users/mikhailpanyushkin/code/mtube/vendor/livewire/livewire/src/WithFileUploads.php on line 17
Looks like with Cors Proxy i don't get filename?