Boa tarde, estou com um problema e não consegui resolver de nenhum jeito. Preciso buscar informações para criar um lista.
Tentei todas as formas de access-control, adicionei o plugin whitelist, ajustei meus origins no XML.
Preciso de HELLPPPP. rsrsr
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
index.html:1 XMLHttpRequest cannot load http://www.santorock.com/api/catalog_system/pvt/category/tree/3/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 405.
//CONFIG XML
<access origin="https://ajax.googleapis.com/ajax/" />
<access origin="http://santorock.com.br/" />
<access allows-arbitrary-loads-in-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*" />
var settings = {
"async": true,
"crossDomain": true,
"url": "http://www.santorock.com/api/catalog_system/pvt/category/tree/3/",
"method": "GET",
"headers": {
"content-type": "application/json",
"x-vtex-api-appkey": "dev.rodrigovitorelli@gmail.com",
"x-vtex-api-apptoken": "Rodrigo13",
"Access-Control-Allow-Methods": "GET, POST, PATCH, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Origin, Content-Type, X-Auth-Token",
"Access-Control-Allow-Headers": "Authorization",
"Access-Control-Allow-Origin": "*"
},
"permissions": [ 'http://localhost:8000']
}
$.ajax(settings).done(function (response) {
var nomeCategoriaPai = response;
var categoriaPai = response.length;
for(var i=0; i < categoriaPai; i++){
nome = nomeCategoriaPai[i].name;
url = nomeCategoriaPai[i].url;
$("body").append('<li><a href="'+url+'">'+nome+'</a></li>');
}
});