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

109
Visualizações
Firebase Login Fails on Localhost but works in Production

Code relevant to the issue

<SimpleButton
  onClick={this.onClickLogin}
  disabled={!this.isEmailPasswordValid()}
  style={{ width: '50%' }}
  id="gi-auth-modal-log-in-button">
    Log In
</SimpleButton>
async onClickLogin() {
    const that = this;
    this.props
      .loginWithPassword(that.state.email, that.state.password)
      .then(() => {
        that.props.closeModal();
      })
      .catch(e => console.log(e))
  }
export const loginWithPassword = (email, password) => async (dispatch) => {
  return await firebase
    .auth()
    .signInWithEmailAndPassword(email, password)
    .then(async (userData) => {
      await dispatch(login(userData));
    })
    .catch(handleFirebaseError);
};

When I run this project on localhost and try to login (with valid credentials), onClickLogin catches the following error:

{
    "code": "auth/invalid-api-key",
    "message": "Your API key is invalid, please check you have copied it correctly."
}

The error message seems simple enough but here is the kicker: the same code works in production. My assumption is that since this code works in production but not on localhost it is some kind of environment configuration issue.

Please help me understand what it can be and should there be any differences in login behavior between dev and production (assuming the same DB is used for both).

Firebase code for reference:

import * as firebaseAdmin from 'firebase-admin';

const firebaseConfig = {
  apiKey: process.env.FIREBASE_KEY,
  projectId: process.env.FIREBASE_PROJECT_ID
};
firebaseAdmin.initializeApp(firebaseConfig);
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

late answer but I had the same problem. Do you have any Allow CORS extension installed? Try to toggle it to off and try again.

about 4 years ago · Juan Pablo Isaza Relatório

0

Make sure you added localhost in the authorized domains list in your firebase project

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