This samples shows how to serve server-side generated HTML pages using the HandlebarsJs templating system.
It also shows how to serve user specific content by passing the Firebase ID token of the signed-in user in a __session cookie.
Checking and decoding the ID token passed in the __session cookie is done with an ExpressJs middleware.
Some custom scripts in [functions/views/layouts/main.handlebars] maintain the Firebase ID token in the __session cookie.
- Create a Firebase Project using the Firebase Console.
- Enable the Google Provider in the Auth section.
- Clone or download this repo and open the
template-handlebarsdirectory. - You must have the Firebase CLI installed. If you don't have it install it with
npm install -g firebase-toolsand then configure it withfirebase login. - Configure the CLI locally by using
firebase use --addand select your project in the list. - Install dependencies locally by running:
cd functions; npm install; cd -
This sample comes with a web-based UI for testing the function. To test locally do:
- Start serving your project locally using
firebase serve --only hosting,functions - Open the app in a browser at
https://localhost:5000. - Sign in the web app in the browser using Google Sign-In and some user information will be displayed on a server-side generated page.
To deploy and test the app on prod do:
- Deploy your project using
firebase deploy - Open the app using
firebase open hosting:site, this will open a browser. - Sign in the web app in the browser using Google Sign-In and some user information will be displayed on a server-side generated page.
We'd love that you contribute to the project. Before doing so please read our Contributor guide.
© Google, 2017. Licensed under an Apache-2 license.