Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda