Firebase Hosting
Last updated
Was this helpful?
Last updated
Was this helpful?
is a Google solution for hosting static websites.
This tutorial will use the production environment, but the steps for the staging environment are the same.
Go to the frontend environment configuration:
frontend/src/config/production.tsx (For React and Vue)
frontend/src/environments/environment.production.ts (For Angular)
Replace the backendUrl
variable for the corresponding URL.
Don't forget the/api
suffix.
Go to and create a Firebase account.
Go to the frontend folder, and run:
Mark only the Hosting option.
Select Use an existing project.
Select the production project.
When asked:
What do you want to use as your public directory?
build (for React)
dist (for Vue)
dist/frontend (for Angular)
Configure as a single-page app (rewrite all urls to /index.html)?
Answer Y.
The firebase.json file will look like this:
Change the .firebaserc to manage both staging and production environments.
On the frontend/package.json, add those two new scripts:
npm run build:<environment>
build the environment using the proper config file. That's needed to build the app with the correct backendUrl.
firebase use <environment>
makes sure the files will be deployed to the correct environment.
firebase deploy
deploys the files.
You will now receive the frontend URL.
Go to the configuration file and replace those values:
Redeploy the application.
To add a custom domain, follow those steps: