0
votes
firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
      // User is signed in.
      console.log("ADMIN is IN");
     // window.location.href = "admin.html"
    } else {
      // No user is signed in.
      console.log("No ADMIN");
      window.location.href = "login.html";
    }
  });


function logout(){
    console.log("Function RAN");
    firebase.auth().signOut()
  .then(function() {
    console.log("FINE LOGOUT WORKED");
    window.location.href = "login.html";
  })
  .catch(function(error) {
    console.log(error);
  });
  }

Question 1:- here is my code it work fine on localhost but when i deploy it to firebase hosting it doesn't work?

Question 2:- Can i generate static html files from Cloud function to serve on firebase hosting.

2
For question 1: what happens deployed? Can you sign in properly and so on. If you could give a clear step by step of what happens on localhost vs deployed, that would help. Also, might be worth noting what sign in mechanisms you are using - thanks! - Ian Barber
Yes, Sign In works properly on localhost and on firebase hosting. Only facing problem with logout. when deployed if I go to application tab inside inspect and delete local Storage / Session Storage and cookies then it logout. I am using Email/Password sign in Method. Thanks - Sh Malik
Does the error log output anything? From your code it looks like there should be some log output in either case - Ian Barber
there is no error as it run .then funtion "console.log("FINE LOGOUT WORKED");" I have to manually delete Applciation localStorgae then i get logout. you can check at notification-te.firebaseapp.com/admin.html admin@admin.com password now its working fine - Sh Malik
Hey Sh Malik, I noticed you double include libraries in your code firebase.js and firebase-app.js and firebase-auth.js. Can you remove one version and keep the other. I can see the issue in your app but I am having a problem replicating it on my end. - bojeil

2 Answers

1
votes

Ok, I can confirm the issue is because you are double including the same Firebase source code. When I removed one version, the code works. Either use the hosting provided source code or the gstatic versions. You can't use both.

0
votes

For question 2: Yes! Take a look at the docs page on serving dynamic content with Cloud Functions