Answer the question
In order to leave comments, you need to log in
Fetch request fails, CORS problem, how to solve?
Good afternoon!
I'm making a widget 37.46.128.6 posted on the test server, it requests my server. I have 'Access-Control-Allow-Origin': '*' on my nginx server, swears at 'Access-Control-Allow-Origin' in the console
fetch('https://bc4e9c9a.ngrok.io/widget/generate', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
terminal_id: dataTerminalId,
amount: dataAmount,
organization_id: dataOrganizationId,
user_id: dataUserId
})
}).then((response) => {
response.json().then(function (json) {
if (json) {
qr.setAttribute("src", json.qr);
iframe.setAttribute("src", json.iframeSrc);
iframe.setAttribute('frameBorder', '0');
url = json.iframeSrc;
operationId = json.operationId;
}
});
});
request.open('get', 'https://bc4e9c9a.ngrok.io/widget_evolpay.html', true);
// request.setRequestHeader('Access-Control-Allow-Origin', 'http://37.46.128.6/');
request.onload = function () {
if (request.status >= 200 && request.status < 400) {
console.log(1);
let resp = request.responseText;
document.querySelector('#widget-evolpay').innerHTML = resp;
r();
}
};
request.send();
Answer the question
In order to leave comments, you need to log in
Forward the request through your server.
You send a POST request to your server and from there you send a POST to bc4e9c9a.
grigorie1990 https://youtu.be/DYR8g_kI9Xs?t=2458
everything is detailed there
https is not here and swears.
Try https://www.npmjs.com/package/fetch-json
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question