title: http returns internal server error while using Firebase hosting and functions with node.js
body: <p>I am getting an Internal Server Error from Firebase hosting and functions with node.js. Im following this tutorial and made sure my code is exactly the same as his: <a href="https://www.youtube.com/watch?v=LOeioOKUKI8&amp;t=1s&amp;pbjreload=101" rel="nofollow noreferrer">https://www.youtube.com/watch?v=LOeioOKUKI8&amp;t=1s&amp;pbjreload=101</a> I even have a database reference to facts.</p>
  <p>Here is my index.js file:</p>
  <pre><code>const functions = require('firebase-functions');
  const firebase = require('firebase-admin');
  const express = require('express');
  const engines = require('consolidate');
  
  const firebaseApp = firebase.initializeApp(
      functions.config().firebase
  );
  
  function getFacts() {
      const ref = firebaseApp.database().ref('facts');
      return ref.once('value').then(snap =&gt; snap.val()); 
  }
  
  const app = express();
  app.engine('hbs', engines.handlebars);
  app.set('views', './views');
  app.set('view engine', 'hbs');
  
  
  app.get('/', (request, response) =&gt; {
      response.set('Cache-Control', 'public, max-age=300, s-maxage=600');
      getFacts().then(facts =&gt; {
          response.render('index', { facts });
      });
  });
  
  exports.app = functions.https.onRequest(app);
  
  </code></pre>
  <p>Here is my index.hbs file:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1&quot;&gt;
      &lt;title&gt;true facts.&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;h1&gt;true facts.&lt;/h1&gt;
  
      &lt;ul&gt;
          {{#each facts}}
          &lt;li&gt;{{text}}&lt;/li&gt;
          {{each}}
      &lt;/ul&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>Firebase.json file:</p>
  <pre><code>{
    &quot;hosting&quot;: {
      &quot;public&quot;: &quot;public&quot;,
      &quot;rewrites&quot;: [{
        &quot;source&quot;: &quot;**&quot;,
        &quot;function&quot;: &quot;app&quot;
      }],
      &quot;ignore&quot;: [
        &quot;firebase.json&quot;,
        &quot;**/.*&quot;,
        &quot;**/node_modules/**&quot;
      ]
    }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/HVmWY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HVmWY.png" alt="database reference" /></a></p>
  <p><a href="https://i.stack.imgur.com/kAt9Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kAt9Q.png" alt="internal_server_error" /></a></p>
  <p><a href="https://i.stack.imgur.com/3YugP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3YugP.png" alt="my_coding_folder" /></a></p>
  <p>Firebase Functions log error message:</p>
  <pre><code>app
  Error: Parse error on line 21: ...ul&gt;&lt;/body&gt;&lt;/html&gt; --------------------^ Expecting 'OPEN_INVERSE_CHAIN', 'INVERSE', 'OPEN_ENDBLOCK', got 'EOF' at Parser.parseError 
  (/srv/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:267:19) at Parser.parse 
  (/srv/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:336:30) at parseWithoutProcessing 
  (/srv/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:46:33) at HandlebarsEnvironment.parse 
  (/srv/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:52:13) at compileInput 
  (/srv/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:508:19) at ret 
  (/srv/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:517:18) at /srv/node_modules/consolidate/lib/consolidate.js:935:16 at /srv/node_modules/consolidate/lib/consolidate.js:161:5 at Promise._execute 
  (/srv/node_modules/bluebird/js/release/debuggability.js:384:9) at Promise._resolveFromExecutor 
  (/srv/node_modules/bluebird/js/release/promise.js:518:18) at new Promise 
  (/srv/node_modules/bluebird/js/release/promise.js:103:10) at promisify 
  (/srv/node_modules/consolidate/lib/consolidate.js:154:10) at Function.exports.handlebars.render 
  (/srv/node_modules/consolidate/lib/consolidate.js:925:10) at /srv/node_modules/consolidate/lib/consolidate.js:180:25 at readPartials 
  (/srv/node_modules/consolidate/lib/consolidate.js:116:33) at /srv/node_modules/consolidate/lib/consolidate.js:174:7
  </code></pre>