I have express, react based existing project that I managed to port to Firebase hosting with cloud functions successfully..at least on the dev server.
It looks like this..
This is running on http://localhost:5000/ with command
firebase serve --only functions,hosting
Now, when I deploy this, it looks like
This is NOT a static site. Following the firebase vid here
https://www.youtube.com/watch?v=LOeioOKUKI8
So I have express server running with
app.use('/static',express.static('../public'));
I had to do this because otherwise, firebase hosting treats each path as public path and it messes up scripts sourcing from public folder and also my react router in react app.
While this works on local server run by firebae, it throws 404 on prod.
Failed to load resource: the server responded with a status of 404 ()
The point is I got all this working on local machine but the deployment just won't oblige.
The deployment was not smooth.
firebase deploy
didn't work.
firebase --only hosting
worked.
firebase --only functions
did not work for quite sometime.
It kept throwing
Error setting up the execution environment for your function. Please try again after a few minutes.
a few times before it finally worked. And I didn't change anything to make it work. Just did it by itself.
Is there something I am missing? I am very new to firebase hosting.
I already have a production site running somewhere and I wish to port it to firebase. But I can not have random 'try again after a few minutes problems'.
But first things first, why are my static files not rendering on prod when they do on dev?
Thanks
Your public directory will need to be nested beneath your functions folder, as only files within the functions folder are deployed to Cloud Functions and available from Node.js.
The local emulator is not actively guarding against this kind of tree navigation, which is why it works locally.
In general, though, you'll likely want to restructure your app a bit so that your static assets are deployed to Firebase Hosting directly rather than being served by Express.
Related
I have created a simple todo app for learning purposes. It is a full stack website that consists of a static html file with js script that is accessing api on the same host. Backend is build on node.js with express framework and mongodb. Everything works fine on a local server, that I start with cmd:
firebase serve --only functions,hosting
However when I deploy the app to the firebase cloud with cmd:
firebase deploy
I cannot access JSON file that should be served under /api/todos. Instead I receive 503 error:
The app/api/todos also does not work and gives error: Cannot GET /app/api/todos
I can access the file locally:
How can I access my JSON file after the deployment? How the route /app/api/todos would be translated in the app that is deployed?
You should rewrite your /api route from hosting to functions in firebase.json file
Take a look to this link
I successfully deployed my Vue app using Firebase hosting except for one small thing - the database that I was running from localhost isn't appearing / being referenced when I navigate to the hosting URL (https://.firebaseapp.com.
Instead, any changes I make in attempt to recreate the data on the hosted site only effects my instance running on localhost!
Basically:
Why am I not seeing any db data once i deploy using the standard firebase commands firebase init and firebase deploy?
When I deploy how can I use the same database from localhost but have it running as a copy so that the deployed database and localhost database are kept separate?
I answered the first part via changing how I was deploying. Screenshot is attached.
I answered the second part through this post
I have a problem with a web hosting project. I created a new proyect in google firebase, and I executed the following commands:
C:\myproject>firebase init functions
C:\myproject>firebase deploy --only functions
But the site says this:
Site Not Found
Why am I seeing this?
There are a few potential reasons:
You haven't deployed an app yet.
You may have deployed an empty directory.
This is a custom domain, but we haven't finished setting it up yet.
How can I deploy my first app?
Refer to our hosting documentation to get started.
What could I do for show, at least, some text when an user go to my project url?
The way you now invoke the Firebase CLI, it will only deploy the Cloud Functions in your project. It will not deploy the web site. In fact, the way you've run it, it probably didn't even create a web site to deploy.
Initialize the project with:
firebase init
And answer the questions this shows.
If you want to deploy the web site, use:
firebase deploy --only hosting
More likely you should simply deploy everything to prevent running into this problem:
firebase deploy
I have problem with my application, which is normally working locally, but when I deploy it on Heroku, then it crashes.
My repo: https://github.com/gkucmierz/cors-proxy
If you search for:
node.js deploy to heroku
You will find that there are certain restrictions to uploading a node.js on heroku.
You should include an application.yml file.
You should include a procfile.
You should modify any interactions with databases to work with postgresql.
I hope I could help.
I am trying to set up a very simple website using firebase and the hosting service. I installed node.js v6 following the official instructions provided on their website for Ubuntu. Then I installed firebase and tried to deploy my website following these instructions.
Unfortunately, I ran through several problems.
The firebase login worked fine and the firebase init command appeared to have worked fine too. I then added a very simple index.html file to my folder and then used firebase deploy. The command output told me the website had been successfully deployed, but it was not. The website is not found when I try to reach it with my browser, and the firebase online hosting utility tells me nothing was deployed.
I then checked my firebase.json file and noticed it only contained this :
{}
It's been more than a day now, so I don't think their servers could be that slow at deploying my website, which is very light.
I've tried reinstalling everything, but nothing changed unfortunately...