Answer the question
In order to leave comments, you need to log in
How to bypass CORS and upload photo to server using VK API?
Good afternoon! I am writing VK miniapps and faced a problem that I can't upload photos to the server.
1. I get the server:
const serv = yield currectBridge.send('VKWebAppCallAPIMethod', {
method: 'photos.getUploadServer',
params: {
album_id: 000, //мой открытый альбом
owner_id: userId,
v: '5.21',
access_token: userToken,
},
});
let formData = new FormData();
formData.append('field1', canvas.toDataURL());
let response = yield fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
//mode: 'no-cors',
body: formData,
});
Access to fetch at ' https://pu.vk.com/c842229/ss2120/upload.php?act=do... ' from origin ' https://stage-app70008-d852483adfb2.pages.vk-apps.com ' 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.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question