「Gcp/Firebase/CloudFunctions/Basic認証」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==hostingでbasic認証の作り方== #firebase init functions function/index.js <pre> const functions = require('firebase-functions') const express = require('express')...」) |
(相違点なし)
|
2022年11月6日 (日) 06:18時点における版
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