クラウド機能を使用して動的ページを作成しようとしていますが、ローカルでcliを使用しているときにIamがpublicフォルダからindex.htmlページを取得しています。Firebase Hostingを使用したFirebase Cloud機能:firebase.json "書き換え"
私はfirebaseでホスティング、機能を導入しようとしたが、問題はまだ立って、以下のコードをしようとIAMためだから、パブリックフォルダ
からindex.htmlページを取得IAMだった - 私は私が間違っている必要がありますだと思います」 「書き直す」。
/functions/index.js我々はhttps://example.firebaseapp.com/を打ったとき、私たちはBIGBEN機能応答データを取得する必要がありますされてIAMは何をしようとして
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"
} ]
}
}
。
手を挙げてください!
ありがとう@Michael Bleigh、パブリックディレクトリからindex.htmlを削除した後、私は自分の関数からresを取得します。 –