メモ
firebase-toolsをインストール
- npm install -g firebase-tools
firebaseの初期化
- firebase init
- hosting と functions を選択
- 適当に選択
- javascript or typescript が出てきたときに typescriptを選択
expressをインストール
- cd functions
- npm install –save express
expressでルーティング
- ./functions/src/index.ts にルーティング処理を記載
- exports.app = functions.https.onRequest(app); // app = express()
rewrites処理を記載
- ./firebase.json にrewritesを追加
- “hosting” に “rewrites”: [{“source”: “**”, “function”: “app”}] を追加
- appはexportsしたものと同じ名前
localサーバを起動
- firebase serve
- ※ firebase serve –only hosting,functions で起動しろと書いてあるが、そうすると動的コンテンツのほうが動かなかった。。。