Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

325
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda