cancel
Showing results for 
Search instead for 
Did you mean: 

CORS error in getHostedPaymentPageRequest API call using Java script

Getting the below error message while calling the API. I have added all the possible options in the header. Please take a look at the JS code and the error message below and suggest me a solution.

JS Code:

--------------

xhr.open("POST", "https://apitest.authorize.net/xml/v1/request.api");
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
xhr.setRequestHeader("Access-Control-Allow-Headers", "Origin, Accept, Accept-Encoding, Connection, Content-Type, cache-control, method, X-Requested-With, Access-Control-Request-Method, Access-Control-Request-Headers,Authorization,X-Auth-Token");
xhr.setRequestHeader("Access-Control-Allow-Methods","GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS");
xhr.setRequestHeader("Content-Type", "application/json");
//xhr.setRequestHeader("Access-Control-Allow-Origin", "application/json");
xhr.send(data);

 

Error:

----------

Access to XMLHttpRequest at 'https://apitest.authorize.net/xml/v1/request.api' from origin 'https://****.com' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.

6 REPLIES 6

Ensure that the domain with the Access-Control-Allow-Origin header is exactly the same as the one your are calling https://apitest.authorize.net/xml/v1/request.api from. For example www.domain.com is considered to be a diffferent domain than domain.com, as is the port https vs http.

 

If you have a public URL that you are https://apitest.authorize.net/xml/v1/request.api from, we could inspect it for you.

Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

Thanks for your response. It is resolved after removing all the headers.

Getting a Telegram assembling to that size is certainly not a basic achievement and do you anytime need 200,000 people in your social event? To help you with guiding your social occasion to the right size, Telegram offers both treadtopic Telegram Public Group and Telegram Private Groups.

treadingtops
Member

know we are entertaining with some whatsapp group links not to verified to here just close your eyes and click here you may land in the page it will help you

priyanak
Member

for its you need a good tech news so lets clcik it and get good js code definder

gstechnews
Member

"Learn all about CORS, the difference between simple and preflighted requests

and how to add CORS support to an existing Node Express app! "

alexally
Member