简体   繁体   English

为什么我会收到 404 错误,没有 Firebase 应用“[DEFAULT]”是什么意思?

[英]Why do I get a 404 error and what does no Firebase App '[DEFAULT]' mean?

What does it exactly mean and how do I solve it?它到底是什么意思,我该如何解决?

Failed to load resource: the server responded with a status of 404 ()
firebaseNamespaceCore.ts:106 Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase
App.initializeApp() (app/no-app).
     at f (https://www.gstatic.com/firebasejs/7.9.1/firebase.js:1:73499)
     at Object.i [as auth] (https://www.gstatic.com/firebasejs/7.9.1/firebase.js:1:73757)
     at https://superx-bcf15.web.app/:37:22

The error messages you provided are actually two separate errors.您提供的错误消息实际上是两个单独的错误。

The 404 Error 404 错误

The first error message,第一条错误信息,

Failed to load resource: the server responded with a status of 404 ()

is caused by是由

<script src="js/app.js"></script>

where the file https://superx-bcf15.web.app/js/app.js doesn't exist.其中文件https://superx-bcf15.web.app/js/app.js不存在。

The Firebase '[DEFAULT]' app Firebase“[DEFAULT]”应用

firebaseNamespaceCore.ts:106 Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call FirebaseApp.initializeApp() (app/no-app).

This error message indicates that you haven't called firebase.initializeApp() to pass in the required configuration parameters before trying to use the SDK elsewhere.此错误消息表明您在尝试在其他地方使用 SDK 之前尚未调用firebase.initializeApp()来传入所需的配置参数。

In your code, you try to call firebase.auth() before calling firebase.initializeApp() here:在您的代码中,您尝试在此处调用firebase.auth()之前调用firebase.initializeApp()

<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase.js"></script>
<script>
    firebase.auth().onAuthStateChanged(function(user){
        if(user){
            window.location.href = "admin.html";
        }
    });
</script>

You need to change that to你需要把它改成

<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase.js"></script>
<script>
    firebase.initializeApp(/* your firebase config here */);
    firebase.auth().onAuthStateChanged(function(user){
        if(user){
            window.location.href = "admin.html";
        }
    });
</script>

These steps are well documented in the Getting Started documentation .这些步骤在Getting Started 文档中有详细记录

Because you are using Firebase Hosting, you can also use the built-in helper script to call initializeApp() with the configuration needed for your project automatically (as you can see here ):因为您使用的是 Firebase 托管,您还可以使用内置的帮助程序脚本自动调用initializeApp()并使用您的项目所需的配置(如您所见):

<script src="https://www.gstatic.com/firebasejs/7.9.1/firebase.js"></script>
<script src="/__/firebase/init.js"></script>
<script>
    firebase.auth().onAuthStateChanged(function(user){
        if(user){
            window.location.href = "admin.html";
        }
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会收到“ UnhandledPromiseRejectionWarning”,这是什么意思? - Why do I get “ UnhandledPromiseRejectionWarning” and what does it mean? 这个错误“null is not an object”是什么意思? 我该怎么办? - What does this error "null is not an object "mean? And what should I do? 这个错误是什么意思,我该如何解决? - What does this error mean and how do I fix it? 如果我用jquery达到“最高”,那是什么意思? - If I get “top” with jquery, what does it mean? 部署Firebase云function时这个错误是什么意思 - What does this error mean when deploying Firebase cloud function 为什么我总是在此函数上得到404? - why do i always get a 404 on this function? “!default”对依赖项意味着什么 - What does “!default” mean for a dependency 当我在 jQuery 中运行 $.get 时,我收到“object Object”。 为什么? 究竟是什么意思? - When I run $.get in jQuery I receive "object Object". Why? What does mean exactly? 为什么我收到错误:运行 npm ci &amp; run npm 构建失败时,将更改推送到部署在 Firebase 上的 React 应用程序? - Why do I get error: run npm ci & run npm build failed when pushing changes to React app that is deployed on Firebase? 使用“dotnet new react -o my-app”中的默认代码时,为什么会出现 JSON.parse 错误? - Why do I get JSON.parse error when using default code from “dotnet new react -o my-app”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM