Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

326
Views
Firebase Real Time Database - CORS header ‘Access-Control-Allow-Origin’ missing

I've just set up a Firebase real time database with default configuration. I'm using JavaScript to import the Firebase SDK via CDN since I can't use npm for now.

I know several similar questions have been asked and this one in particular is close to the problem I'm facing presently but none of the solutions there seem to work. I've allowed domains, edited the database rules for public access and tried different browsers but the problem persists.

Here's my import code:

<script type="module">
    import {
        initializeApp
    } from "https://www.gstatic.com/firebasejs/9.6.11/firebase-app.js";

    import {
        getDatabase
    } from "https://XXXXX-default-rtdb.europe-west1.firebasedatabase.app"; //path to my db location

    const firebaseConfig = {
        apiKey: "XXXXXXXXXXXXXXX",
        authDomain: "XXXXX.firebaseapp.com",
        databaseURL: "https://XXXXX-default-rtdb.europe-west1.firebasedatabase.app", //path to my db
        projectId: "XXXXX",
        storageBucket: "XXXXX.appspot.com",
        messagingSenderId: "1111111111",
        appId: "1:1111111:web:XXXXXX"
    };

    const app = initializeApp(firebaseConfig);

    const database = getDatabase(app);
</script>

What could I be doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is wrong:

import {
    getDatabase
} from "https://XXXXX-default-rtdb.europe-west1.firebasedatabase.app"; //path to my db location

You can't import the API from the location of your database. You need to import the SDK from the CDN that it's on, similar to what you do for initializeApp right above it:

import {
    initializeApp
} from "https://www.gstatic.com/firebasejs/9.6.11/firebase-app.js";

So something like:

import {
    getDatabase
} from "https://www.gstatic.com/firebasejs/9.6.11/firebase-database.js";
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!