我想从另一个URL下载视频文件,但不适用于我的laravel项目。而我收到此错误
Access to XMLHttpRequest at 'http://localhost/blog/public/uploads/video/1543647797BirdNoSound.mp4' from origin 'http://103.54.150.38:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
我已经在我的laravel项目中安装了https://packagist.org/packages/spatie/laravel-cors
这个包
这是我的vue js代码
axios({
url: 'http://103.54.150.38/blog/public/uploads/video/1543647797BirdNoSound.mp4',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
FileSaver.saveAs(new Blob([response.data]));
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'video_file.mp4'); //or any other extension
document.body.appendChild(link);
link.click();
});