我正在尝试从vue proyecto上传视频,但出现错误
Access to XMLHttpRequest at 'url' from origin 'http://localhost:8080' has been blocked by CORS policy: Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response.
我正在遵循本指南guide,并且在第二步中抛出错误,我正在这样做
const files = $event.target.files[0];
axios
.post(
"https://api.vimeo.com/me/videos",
{},
{
headers: {
"Authorization": "bearer access_token",
"Content-Type": "application/json",
"Accept": "application/vnd.vimeo.*+json;version=3.4"
}
}
)
.then(({ data }) => {
let formData = new FormData();
formData.append("file", files);
axios // <--- here it fails with cors
.patch(data.upload.upload_link, formData, {
headers: {
"Tus-Resumable": "1.0.0",
"Upload-Offset": 0,
"Content-Type": "application/offset+octet-stream",
"Accept": "application/vnd.vimeo.*+json;version=3.4",
}
})
.then(response => {
console.log("response", response);
});
在第一段中说它在前端工作,所以我不明白为什么出现cors错误,我做错什么了吗?我想念什么吗?