AllAnimals AllAnimals - 1 year ago 100
Javascript Question

Angular $http.get with firebase

I am trying to access information from my firebase database using the $http service. This is my code:

$http.get("my firebase url").then(function(res) {

But I am getting a cors error:
XMLHttpRequest cannot load Redirect from '' to '…owup=' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Ive tried googling the issue but I couldnt find anything that I understood.

Note: I am a firebase and angular noobie.

Answer Source

I hope this helps.

You will need 3 things to be considered. 1. On the URL use your FB domain not the console "Ex:"
2. At the end, you will need to extend the url to .json "Ex: ../settings/app.json"
3. And you will need to use rules to allow the access:

    "rules": {
        ".read": "auth != null",
        ".write": "auth != null",
        "settings": {
            "app": {
                ".read": true,
                ".write": false

Then you can use your $http, as in my example:


enter image description here

Example here :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download