[英]Errors after deploying my flutter web app using Firebase Hosting
I've tried to deploy my web app but when I go the the public adress, I have some errors that i can't fix.我已经尝试部署我的网络应用程序,但是当我访问公共地址时,我遇到了一些无法修复的错误。 (I'm testing on Firefox).
(我正在 Firefox 上测试)。 I've asked my developper friends but they have no idea how to solve it.
我问过我的开发人员朋友,但他们不知道如何解决。
my errors:我的错误:
The script was loaded when its MIME type ("text / html") is not a valid JavaScript MIME type.
脚本在其 MIME 类型(“text / html”)不是有效的 JavaScript MIME 类型时加载。
Uncaught SyntaxError: expected expression, got '<' main.dart.js:1
未捕获的语法错误:预期的表达式,得到 '<' main.dart.js:1
my index.html:我的 index.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>MyAwesomeWebApp</title> <!-- Favicon --> <link rel="icon" type="image/png" href="favicon.png"/> <link rel="manifest" href="manifest.json"/> </head> <body> <script type="application/javascript" src="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.min.js"></script> <script type="application/javascript"> pdfjsLib.GlobalWorkerOptions.workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.worker.min.js"; </script> <script type="application/javascript" src="https://www.gstatic.com/firebasejs/7.14.0/firebase-app.js"></script> <script type="application/javascript" src="https://www.gstatic.com/firebasejs/7.14.0/firebase-analytics.js"></script> <script type="application/javascript" src="https://www.gstatic.com/firebasejs/7.14.0/firebase-firestore.js"></script> <script type="application/javascript" src="https://www.gstatic.com/firebasejs/7.14.0/firebase-auth.js"></script> <script type="application/javascript" src="https://www.gstatic.com/firebasejs/7.14.0/firebase-storage.js"></script> <script> var firebaseConfig = { apiKey: "azaz", authDomain: "azaz", databaseURL: "azaz", projectId: "azaz", storageBucket: "azaz", messagingSenderId: "azaz", appId: "azaz", measurementId: "azaz" }; firebase.initializeApp(firebaseConfig); </script> <script> if ('serviceWorker' in navigator) { window.addEventListener('flutter-first-frame', function () { navigator.serviceWorker.register('flutter_service_worker.js?v=906927181'); }); } </script> <script src="main.dart.js" type="application/javascript"></script> </body> </html>
Thanks !谢谢 ! :D
:D
did you deploy using firebase deploy
or firebase deploy --only hosting
?您是使用
firebase deploy --only hosting
firebase deploy
还是firebase deploy --only hosting
? I had the same issue using the first one.我在使用第一个时遇到了同样的问题。 With the second one, no more issue.
有了第二个,就没有问题了。 You can learn more about this on the firebase documentation: https://firebase.google.com/docs/hosting/test-preview-deploy
您可以在 firebase 文档中了解更多相关信息: https : //firebase.google.com/docs/hosting/test-preview-deploy
Hope it'll be helpful !希望它会有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.