Mengatasi CORS di Firebase

Tutorial singkat cara mengatasi CORS di Google Firebase
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated
cors origins not allow

Access to fetch at 'REALTIME-DATABASE-URL' from origin 'https://dereloading.blogspot.com/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


Berulang kali saya coba melakukan beberapa CRUD operation menggunakan Realtime database hasil nya seperti di atas has been blocked by CORS policy.

Mungkin karena saya tidak membaca dokumentasi dengan benar , karena setelah saya breakdown ulang tertulis di situ kita harus setting cors pada console.google.cloud.
dokumentasi google firebase
Dan apabila kalian merasakan hal yang sama , mari perbaiki masalah tersebut 🤔.
Masuk ke cloud.google.com pilih project kalian.
Aktifkan cloud shell setelah aktif buka terminal , pada jendela terminal tulis
$ nano cors.json
ketika editor sudah muncul ketik kode json seperti di bawah :
[
  {
    "origin": ["*"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
  }
]

* itu artinya seluruh domain yang termasuk memiliki akses , terkecuali mengganti nya dengan https://bloggue.com/ hanya domain ini yang memiliki akses.

Kemudian pada keyboard tekan CTRL + X lalu tekan y jalankan perintah seperti dibawah ini :
$ gsutil cors set cors.json gs://URL-BUCKET-PROYEK

Setelah anda tekan enter anda sudah berhasil Mengatasi CORS di Firebase.
url bucket proyek dapat diketahui dari gs://<namaproject>.appspot.com
sampai disini kita sudah selesai Mengatasi CORS di Firebase.

Getting Info...

Post a Comment

Agiel Triono Comment Policy

Do not include spam link !
Please read our Comment Policy before commenting.
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.