0

尝试使用包裹编译博客网站时,应用程序 firebase 未定义错误。我使用 parcel 是因为我使用 editorjs 来制作我的博客编辑器。由于某种原因,所有的 firebase 身份验证都不起作用,我不知道该怎么做。

我已经尝试将包裹更新到最新版本。我已经在网上寻找答案,但我似乎是唯一一个遇到这个问题的人。

由于该错误,无法登录应用程序或获取任何已登录用户的数据。有谁知道如何解决这一问题?

在浏览器控制台中,我收到此错误:

Uncaught ReferenceError: app_firebase is not defined
at signIn.js:2
    at Object.parcelRequire.../javascript/signIn.js (signIn.js:1)
    at newRequire (signIn.0c53d6ba.js:47)
    at signIn.0c53d6ba.js:81
    at signIn.0c53d6ba.js:120

虽然节点没有错误

这是signIn.js:

(function() {
    firebase = app_firebase;
    
    // Initialize the FirebaseUI Widget using Firebase.
    var ui = new firebaseui.auth.AuthUI(firebase.auth());
    var uiConfig = {
        callbacks: {
          signInSuccessWithAuthResult: function(authResult, redirectUrl) {
            // User successfully signed in.
            // Return type determines whether we continue the redirect automatically
            // or whether we leave that to developer to handle.
            return true;
          },
          uiShown: function() {
            // The widget is rendered.
            // Hide the loader.
            document.getElementById('loader').style.display = 'none';
          }
        },
        // Will use popup for IDP Providers sign-in flow instead of the default, redirect.
        signInFlow: 'popup',
        signInSuccessUrl: '../html/index.html',
        signInOptions: [
          // Leave the lines as is for the providers you want to offer your users.
          firebase.auth.GoogleAuthProvider.PROVIDER_ID,
          // firebase.auth.EmailAuthProvider.PROVIDER_ID,
        //   firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        //   firebase.auth.TwitterAuthProvider.PROVIDER_ID,
        //   firebase.auth.GithubAuthProvider.PROVIDER_ID,
         
        //   firebase.auth.PhoneAuthProvider.PROVIDER_ID
        ],
        // Terms of service url.
        tosUrl: '<your-tos-url>',
        // Privacy policy url.
        privacyPolicyUrl: '<your-privacy-policy-url>'
      };
        
        // The start method will wait until the DOM is loaded.
        ui.start('#firebaseui-auth-container', uiConfig);
})();

app_firebase 在 fireBase.js 中定义: 出于显而易见的原因,我删除了所有 firebaseConfig 值


    var app_firebase = {};
    //self invoking function to initialize the firebase app
    (function() {
      //meta data of my firestore database
        var firebaseConfig = {
          apiKey: "",
          authDomain: "",
          projectId: "",
          storageBucket: "",
          messagingSenderId: "",
          appId: "",
          measurementId: ""
        };
          // Initialize Firebase
          firebase.initializeApp(firebaseConfig);
    
          app_firebase = firebase;
    })()

4

0 回答 0