Skip to content

[flutter_tools][web]: tools and generated content assume app is hosted in the root of the web host #50580

@kevmoo

Description

@kevmoo

Generated web/index.html has absolute paths to icons, manifest.json, and flutter_service_worker.js

So if the app is at myuser.github.io you're fine.
If your app is at myuser.github.io/my_repo all of the resources will fail!

The content of the generated flutter_service_worker.js is also problematic due to "rooted" /... paths

Generated flutter_service_worker.js looks like below

'use strict';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
  "/index.html": "96174ee0b96776b8e7d289cca7637b01",
"/main.dart.js": "ad1f6dd5d4ec0e1c24930f46d601b869",
"/icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1",
"/icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1",
"/manifest.json": "feb08c467497da9e02cee6e9ca69701d",
"/assets/LICENSE": "610d31457f417aae1367782f0dac0769",
"/assets/AssetManifest.json": "99914b932bd37a50b983c5e7c90ae93b",
"/assets/FontManifest.json": "580ff1a5d08679ded8fcf5c6848cece7",
"/assets/fonts/MaterialIcons-Regular.ttf": "56d3ffdef7a25659eab6a68a3fbfaf16"
};

self.addEventListener('activate', function (event) {
  event.waitUntil(
    caches.keys().then(function (cacheName) {
      return caches.delete(cacheName);
    }).then(function (_) {
      return caches.open(CACHE_NAME);
    }).then(function (cache) {
      return cache.addAll(Object.keys(RESOURCES));
    })
  );
});

self.addEventListener('fetch', function (event) {
  event.respondWith(
    caches.match(event.request)
      .then(function (response) {
        if (response) {
          return response;
        }
        return fetch(event.request);
      })
  );
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: buildBuilding flutter applications with the toolc: new featureNothing broken; request for a new capabilityplatform-webWeb applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions