Я пытаюсь получить значение из приложения angular 2, размещенного в firebase. Когда мы пытаемся, оно показывает ошибку
Не удалось загрузить
https://url/?a1=123&a2=milla: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
index.hmtl:22 XHR finished loading: GET "https://url/?a1=123&a2=milla".
loadXMLDoc @ index.hmtl:22
onclick @ index.hmtl:8
Это мои данные firebase.json
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/timestamp",
"function": "app"
}
],
"headers": [ {
"source" : "index.html",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
} ]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
}
Это мой код ajax для запроса данных из размещенного в firebase приложения angular2
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "https://url/?a2=123&a1=milla", true);
xhttp.send();