Skip to content

Instantly share code, notes, and snippets.

@jackie1santana
Last active May 31, 2020 18:08
Show Gist options
  • Save jackie1santana/f2a7147ed3621b488f0109847fe1e8e0 to your computer and use it in GitHub Desktop.
Save jackie1santana/f2a7147ed3621b488f0109847fe1e8e0 to your computer and use it in GitHub Desktop.
Firebase Hosting
1) npm install -g firebase-tools
2) firebase login
3) firebase init hosting
4) pick folder
5) firebase serve (if u want to see how the site looks in dev)
6) firebase deploy
@jackie1santana
Copy link
Author

jackie1santana commented May 31, 2020

Server side Hosting

  • npm i -g firebase-tools
  • firebase init hosting
  • pick folder (public)
  • firebase init functions
  • server code goes into functions folder
  • cd functions & install express
  • now you should have a firebase public & functions folder
  • go into functions index.js
const functions = require('firebase-functions');
const express = require('express')

const app = express()

app.get('/user', (req, res) => {
    res.send('user')
})

//name this in firebase.json 'app;
exports.app = functions.https.onRequest(app)


  • hook up functions with hosting project by going into the firebase.json
 {
  "hosting": {
    "public": "firebase-hosting",
    "rewrites": [{
      "source": "/user",
      "function": "app"
    }],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}
  • in command line: firebase serve --only functions,hosting
  • set firebase env variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment