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

108
Views
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 answers
Answer question

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 Report

0

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

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!