클라우드 기능을 사용하여 동적 페이지를 만들려고하지만 로컬에서 cli를 사용하여 제공 할 때 Iam은 공용 폴더에서 index.html 페이지를 가져옵니다.Firebase 호스팅 기능이있는 Firebase 클라우드 기능 : firebase.json "rewrites"
, 내가 중포 기지에서 호스팅 기능을 배포 시도했지만 문제가 여전히 유효은 스피하려고 다음과 같은 코드에 대한
그래서 공용 폴더에서 index.html 페이지를 받고 스피했다 - 나는 "문제가 될 생각합니다 부분을 다시 씁니다.
/functions/index.js, 우리가 bigben 기능은 데이터 대응 방법 가야 할 우리가 https://example.firebaseapp.com/을 명중 할 때하려고하고 스피 무엇
{
"hosting": {
"public": "public",
// Add the following rewrites section *within* "hosting"
"rewrites": [ {
"source": "/", "function": "bigben"
} ]
}
}
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
.제발 손 좀주세요!
감사합니다 @Michael Bleigh, public 디렉토리에서 index.html을 제거한 후 내 기능에서 res를 얻습니다. –