Gcp/Firebase/CloudFunctions/Basic認証
提供: 初心者エンジニアの簡易メモ
2022年11月6日 (日) 06:18時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==hostingでbasic認証の作り方== #firebase init functions function/index.js <pre> const functions = require('firebase-functions') const express = require('express')...」)
hostingでbasic認証の作り方
- firebase init functions
function/index.js
const functions = require('firebase-functions') const express = require('express') const basicAuth = require('basic-auth-connect') const app = express() app.all('/*', basicAuth(function(user, password) { return user === 'user1' && password === 'testtest'; })); app.use(express.static(__dirname + '/static/')) exports.app = functions.https.onRequest(app)
firebase.json
{ "hosting": { "public": "public", "rewrites": [ { "source": "**", "function": "app" } ], "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ] } }
- firebase deploy