Using Firebase's reserved hosted URLs for local flutter development - firebase-hosting

I'm developing an app in flutter and deploying it to Firebase hosting.
Firebase hosting and the firebase serve command for local development let you initialize Firebase from a special auto-generated relative URL (/__/firebase/init.js).
This is nice because it allows me to share my project (on github, for example) without including my Firebase configuration.
Sadly, this does not seem to play nice with flutter run -- if I use flutter run, I lose the special URLs, and if I use firebase serve, I lose flutter's hot reload features.
My current workaround is to have the following local files under my app/web/ directory:
__/firebase/init.js # containing firebase.initializeApp(myFirebaseConfig);
__/firebase/7.1.44/firebase-app.js # manually downloaded from the gstatic cdn
__/firebase/7.1.44/firebase-auth.js
# ... (etc)
This works, but:
The __ directory actually gets deployed to Firebase. (Not actually a problem, but it seems wrong)
It's annoying to set this up manually in each local development environment.
Ideally, one should be able to firebase login, firebase init, and then flutter serve, and then automagically have access to the /__/ directory.
Is there already some way to make this happen, and if not, how could we implement it?
(For example, is there a way to extend flutter's local http server to take advantage of the logic that's already in the firebase-tools npm module?)

Related

How to save Flutter web file_picker selections to host directory

There are numerous examples online for using file_picker and uploading to Firestore, SQL etc; but it appears there are none for uploading right to the webhost directory where index.html is being served (i.e ./uploads).
As I am using flutter web in a corporate environment my options for spinning up remote storage options are nearly nil. I merely want my flutter web app to allow users to upload to our own environment (I host my web build off Sharepoint and it works perfect).
The solution for posting to web found here (https://stackoverflow.com/a/65759028/82856) is very close to what I need except for the http.MultipartRequest part as I don't have a server API listening for POST requests. What other options do I have for merely writing uploads to a directory like ./upload? Thanks in advance.

Flutter web deployed with firebase hosting does not respect refresh in Safari

I have a Flutter web app that is deployed on Firebase Hosting. When deploying a new version Safari does not pick up the new version even when doing refresh. I assume this is due to the installed service worker, that will serve the old content. How can one bypass this problem? I know that a hard refresh solves the problem, but that is not a good solution as we cannot expect the users to know to do that.
One alternative that requires client code, would be that I track the current version of the app that is currently loaded, and if that change I create "New version available" screen when I detect that a new version is available, and perform a location.reload(true) call from the client to bypass cache and get the new service worker installed.
Any other options?
In more recent versions, they are appending a random hash on every build to the flutter_service_worker.js URL so it should break the cache and refresh properly.

Deploying Flutter Web App To Hostgator/normal FTP means?

I have been really interested in Flutter for the last few months and have been following the beta Flutter for web information. I was wondering, other than the ones mentioned in the documentation (Firebase, Github, Google Cloud), is there a way to currently test my app via using my Hostgator hosting and use something like Filezilla to publish the application/site?
I understand this is in a beta state. I only ask because the documentation states that there is a way to publish via those services but doesn't mention the way I am asking. I also understand that this is not production-ready.
Thank you all for any help
You can just run:
flutter build web
And then copy the contents of build/web to your web host's document root via a panel or FTP or something else.

Firebase Storage Can't Connect, Retry again

I imported an old project into Firebase when I joined.
On the https://console.firebase.google.com/project/project-name/overview page, when I try to grab the code snippet to initialize my Firebase, the storage bucket shows up with empty URL.
Today, I started a new project, this time, using the Firebase console. After creating the project, the StorageBucket URL showed up in the initialization code snippet automatically.
When I check both project's storage rules, I see the URL pointing to the right places, however, the imported project gives this error under the Storage > Files tab:
It has been like this since day one I imported the project.
When I went to https://console.cloud.google.com/storage/browser to see if the new project I created would show, it did.
Are there any extra steps on my part to get the storage bucket URL to show for the imported project?
Who's this answer for?
If you imported your project into Firebase and having the above issue specifically with your Firebase Storage.
After back and forth with Firebase Support, if you're facing similar problems as mine, here's the approach you can try. I'm trying to replay the conversation and steps given by the Firebase Support
Make sure that you are the owner of the project you are accessing.
If you have multiple Google accounts signed in, Firebase Database can't
seem to connect to the server. Sign into incognito mode
Check in your API Manager if the following are enabled
a) App Engine admin API
b) Firebase Rules API
c) Google Cloud Storage
Check if you have an App Engine app is enabled https://console.developers.google.com/project/_/appengine
Go to Firebase Storage AppManager tab
https://console.cloud.google.com/storage/
a) Add the service account firebase-storage#system.gserviceaccount.com as an owner on the storage bucket: .appspot.com.
b) Additionally, you need to edit the "object default permissions" to allow for similar access.
Now, if you have all the above in place, next step is this:
Add new Server Credentials
In credentials page, ( https://console.developers.google.com/apis/credentials ),
click Create credentials, select API key
Select server key
Put name as "Server key (auto created by Google Service)"
At the time of writing this, creating the Server Key was what got it to work.
A few words:
The issue of not able to use Firebase properly when two accounts are logged in the same browser doesn't plague me anymore. Logged into two accounts, and both Firebase projects are up and running without any issue.
I fixed mine by using the command to work on it using
firebase init storage
This would create the storage after that it would add a storage.rule in which you can update to your liking in your project .
Then you run this command
firebase deploy --only storage
This would initialize the Storage
If you are still having issues check out this link https://stackoverflow.com/a/74750337 which was also provided by firebase for me to fix the error
This is how i fixed mine

Google App Engine: Deployed Source doesn't have Local updates

I'm working with Google App Engine in Eclipse w/ JSP pages in Windows 7.
I already have an app deployed and working, but I am unable to make changes to it for some reason.
If I make changes and debug locally, my localhost page is showing the changes that I implement.
While I am not getting any errors in the deployment, the same changes that work on my local debug are no longer showing up, so I can't update my app.
I thought updating the version number might help, but I had no luck with this.
Any ideas? Thanks.
Are you deploying the same version (as specified in appengine-web.xml) as the default version that is running on your app? If not, you'll have to access your new deployment at http://newversion.appname.appspot.com, or change your default version in app engine to your newly deployed version.
I have had the same problems too, especially when the changes concerned the static pages. Some little things to check:
If you have set an expiration date in your app.yaml, your browser cache could be holding the file.
If it’s specific to the online contents, it could be an intermediary cache (such as a squid server) serving the outdated contents, in which case you’d have to flush the cache to get the new version.
You could start by checking the log on the GAE console to see if the request is received by the server, that would help you debug.
Another trick, if you’re being served an outdated version of http://yourapp.appspot.com/index, try and pass a dummy argument to force the browser to update the version, for instance : http://yourapp.appspot.com/index?p=1