[英]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 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
不存在。
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.