【问题标题】:My Flutter web build pretty well in local but doesn't work in firebase hosting我的 Flutter web 在本地构建得很好,但在 firebase 托管中不起作用
【发布时间】:2021-08-01 10:59:09
【问题描述】:

最近,我尝试将我的 Flutter Web 应用托管到 Firebase 托管中。 flutter build web --release 脚本运行良好,没有任何错误。然后,我将它部署到我的 Firebase 托管。结果,当我单击登录按钮时,什么也没发生。然后我尝试使用firebase serve 在本地运行我的build/web,Web 应用程序运行完美。我跳过了一些步骤还是什么?我陷入了死胡同。

也许我会告诉你这个 gif 是怎么回事。

这是我的web/index.html

<!DOCTYPE html>
<html>
<head>
  <!--
    If you are serving your web app in a path other than the root, change the
    href value below to reflect the base path you are serving from.

    The path provided below has to start and end with a slash "/" in order for
    it to work correctly.

    Fore more details:
    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
  -->
  <base href="/">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="renseki_app">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png"/>

  <title>renseki_app</title>
  <link rel="manifest" href="manifest.json">
</head>
<body>
  <!-- This script installs service_worker.js to provide PWA functionality to
       application. For more information, see:
       https://developers.google.com/web/fundamentals/primers/service-workers -->
  <script>
    if ('serviceWorker' in navigator) {
      window.addEventListener('flutter-first-frame', function () {
        navigator.serviceWorker.register('flutter_service_worker.js');
      });
    }
  </script>
  <script defer src="main.dart.js?version=2" type="application/javascript"></script>
</body>
</html>

This is in firebase hosting

This is in firebase serve (run locally)

【问题讨论】:

  • 可能是 SSL 认证错误。我也遇到过这个问题
  • 您是否将您的应用程序设置为单页网络应用程序?
  • 是的,我在firebase init 时将我的应用设置为单页网络应用

标签: firebase flutter dart firebase-hosting


【解决方案1】:

可能是发生 SSL 认证错误

检查页面并像这样查看控制台 ->

【讨论】:

  • 对不起,我的意思是控制台中没有消息
猜你喜欢
  • 2020-08-18
  • 2015-09-23
  • 2020-08-13
  • 1970-01-01
  • 2014-06-26
  • 2023-02-21
  • 2018-03-07
  • 1970-01-01
  • 2021-09-28
相关资源
最近更新 更多