Hello,
I wrote on a provider script this call ‘https://www.paypal.com/it/cgi-bin/webscr’, but I got an error with paypal that block the request. Is it possible to solve this problem?
Thanks in advance
Giovanni
Access to XMLHttpRequest at ‘https://www.paypal.com/it/cgi-bin/webscr’ from origin ‘http://192.168.1.20:8100’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Hi,
I don’t know if this could help you, but when I make an Http request I add this header:
getWsHeader() {
let tempToken;
const content_type = 'application/json';
tempToken = this.getToken();
const headers = {
'Content-Type': content_type,
'Accept': 'plain/text',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
'Access-Control-Allow-Headers': 'Authorization, Origin, Content-Type, X-CSRF-Token',
'auth': tempToken
};
console.log(headers);
return new HttpHeaders(headers);
}
so the request becomes:
return this.httpClient.post(commandUrl,
commandBody,
{headers: this.getWsHeader(), responseType: 'text'});
cld
Hello,
Thanks for suggestion. We add your code, but we got a different error.
Have you an idea for that error?
Thanks in avance
Here is my code:
paypal(){ //
var data2 = "cmd=_cart&upload=1&business=pag@xxx.com";
console.log(data2);
var config = {
headers : {
‘Content-Type’: ‘application/json’,
‘Accept’: ‘plain/text’,
‘Access-Control-Allow-Origin’: ‘*’,
‘Access-Control-Allow-Methods’: ‘POST, GET, OPTIONS, PUT’,
‘Access-Control-Allow-Headers’: ‘Authorization, Origin, Content-Type, X-CSRF-Token’,
//‘auth’: tempToken
}
};
return Observable.create(observer => {
this.http.post(‘https://www.paypal.com/it/cgi-bin/webscr’,data2,config).subscribe(data =>
{
console.log(‘rispostada4D’,data);//you can format the response from your server
observer.next(data );//and then return data
observer.complete();
});
});
}
Access to XMLHttpRequest at ‘https://www.paypal.com/it/cgi-bin/webscr’ from origin ‘http://192.168.1.20:8100’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.