Iam trying to create a Dynamic page using cloud functions, but when i serve using cli in local, Iam getting the index.html page from public folder.
I tried deploying the functions,hosting in firebase but the problem stands still, were iam getting the index.html page from public folder
So for iam trying the following codes - I think i must be wrong with "rewrites" part.
/functions/index.js
const functions = require('firebase-functions');
exports.bigben = functions.https.onRequest((req, res) => {
const hours = (new Date().getHours() % 12) + 1 // london is UTC + 1hr;
res.status(200).send(`<!doctype html>
<head>
<title>Time</title>
</head>
<body>
${'BONG '.repeat(hours)}
</body>
</html>`);
});
firebase.json
{
"hosting": {
"public": "public",
// Add the following rewrites section *within* "hosting"
"rewrites": [ {
"source": "/", "function": "bigben"
} ]
}
}
What iam trying to do is when we hit https://example.firebaseapp.com/ , we have to get bigben functions response data.
Please some one give your hands!