flutter web app on app engine 404 on flutter.js

242 Views Asked by At

I followed instruction from How to deploy Flutter WebApp using Google AppEngine that consists of mainly.

  1. gcloud app create

  2. Creating basic app from any tool, I chose Android studio and used following values option chosen

  3. creating app.yaml with following

    runtime: python39

    api_version: 1 threadsafe: true

    handlers:

    • url: / static_files: web/index.html upload: web/index.html

    • url: /(.) static_files: web/\1 upload: web/(.)

  4. then executing flutter build web

  5. this complained about api_version and threadsafe so i removed both from the app.yaml file , leaving file like

runtime: python39

handlers:

  • url: / static_files: web/index.html upload: web/index.html

  • url: /(.) static_files: web/\1 upload: web/(.)

  1. then flutter build web works and shows following output

File upload done. Updating service [default]...done. Setting traffic split for service [default]...done. Deployed service [default] to [https://myxyzxyz.uc.r.appspot.com]

You can stream logs from the command line by running: $ gcloud app logs tail -s default

  1. Below is the location of the index.html and flutter.js

C:\projectsxyzprj>dir /s index.html flutter.js Directory of C:\projectsxyzprj\build\web

01/29/2023 02:24 AM 1,862 index.html

Directory of C:\projectsxyzprj\build\web

01/29/2023 02:24 AM 6,458 flutter.js 2 File(s) 8,320 bytes

Directory of C:\projectsxyzprj\web

01/29/2023 01:54 AM 1,872 index.html 1 File(s) 1,872 bytes

 Total Files Listed:
           3 File(s)         10,192 bytes
  1. below is the content of index.html ( auto generated by android studio)
<html>
<head>
  <base href="$FLUTTER_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="riya2">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

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

  <title>riya2</title>
  <link rel="manifest" href="manifest.json">

  <script>
    // The value below is injected by flutter build, do not touch.
    var serviceWorkerVersion = null;
  </script>
  <!-- This script adds the flutter initialization JS code -->
  <script src="flutter.js" defer></script>
</head>
<body>
  <script>
    window.addEventListener('load', function(ev) {
      // Download main.dart.js
      _flutter.loader.loadEntrypoint({
        serviceWorker: {
          serviceWorkerVersion: serviceWorkerVersion,
        }
      }).then(function(engineInitializer) {
        return engineInitializer.initializeEngine();
      }).then(function(appRunner) {
        return appRunner.runApp();
      });
    });
  </script>
</body>
</html>
  1. When I go to https://myxyzxyz.uc.r.appspot.com in browser, the browser window shows the App title correctly but the simple counter app does not appear, in browser dev tools under network tab I see 404 for flutter.js as show below, in chrome as well as firefox.

enter image description here

0

There are 0 best solutions below