Firebase-tools: Flutter Web prod build doesn't work on firebase hosting

Created on 13 Jun 2019  路  11Comments  路  Source: firebase/firebase-tools

[REQUIRED] Environment info


firebase-tools:
v7.0.0


Platform:
macOS 10.14.4

[REQUIRED] Test case

Flutter Web prod build doesn't work on firebase hosting

[REQUIRED] Steps to reproduce

  1. clone Flutter Web hello_world https://github.com/flutter/flutter_web/tree/master/examples/hello_world
  2. build prow with webdev build
  3. init firebase project with hosting only
  4. Copy hello_world/build/* to fitebase/public/
  5. Deploy hosting to firebase
  6. Open https://.firebaseapp.com/#/

[REQUIRED] Expected behavior

Browser should show Hello world page

[REQUIRED] Actual behavior

Browser show blank page

Attention

Most helpful comment

Flutter isn't the issue here. In firebase.json it's set up to redirect everything to /index.html. When I just run firebase emulators:start --only hosting, I get an empty page because (as is clear in the browser developer tools), the .json asset that it tries to load is actually html:

image

Which causes a javascript error:

image

Once I removed the rewrites block from firebase.json, everything worked as expected.

image

Since this isn't a firebase-tools bug, I'm going to close this issue. But let us know if you have any questions! Hope this gets you unblocked!

All 11 comments

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

I went through these processes and was able to successfully deploy the hello_world example to my project (after installing flutter, dart, etc).

Can you provide your firebase.json file (to check any settings there) and maybe run the deploy again with the --debug flag and provide that output?

Hi @bkendall,
I have prepared test project for you.
https://github.com/AlexVegner/firebaseTest

Prerequisites

Make sure that you work with flutter beta chanel:
bash setup.bash
https://github.com/AlexVegner/firebaseTest/blob/master/setup.bash

Init firebase with your project
cd firebase && firebase init

Deploy script
bash deploy.bash

My results:
Firebase doesn't work:
https://test-alex-cb960.firebaseapp.com/#/

Github pages works fine:
https://alexvegner.github.io/firebaseTestWeb/#/

See firebase tool log:
https://github.com/AlexVegner/firebaseTest/blob/master/firebase/firebase-debug.log

Flutter isn't the issue here. In firebase.json it's set up to redirect everything to /index.html. When I just run firebase emulators:start --only hosting, I get an empty page because (as is clear in the browser developer tools), the .json asset that it tries to load is actually html:

image

Which causes a javascript error:

image

Once I removed the rewrites block from firebase.json, everything worked as expected.

image

Since this isn't a firebase-tools bug, I'm going to close this issue. But let us know if you have any questions! Hope this gets you unblocked!

Hi @bkendall,
It works for me.

Hi @bkendall,
can you plz explain me what actually happens when we rewrite all the URLs to index.html

@AlexVegner can u help me ?? i follow your instructions (using .bash files) with a new flutter web app and i obtain a blank page https://linajevanguardistas-2018.firebaseapp.com/#/

@IngMarFlo you can read this article..

https://medium.com/@abhijeetdash1999/flutter-web-with-firebase-hosting-82c341989b37

@AbhijeetDash Thanks a lot, its work !!

Was this page helpful?
0 / 5 - 0 ratings