Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Firebase Hosting,Functions] basic認証付きでサイトを公開する
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"function": "app"
}
],
"redirects": [{
"source": "/",
"destination": "/auth"
}],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
# functions/index.js
const functions = require('firebase-functions')
const express = require('express')
const basicAuth = require('basic-auth-connect')
const app = express()
app.use(basicAuth('username', 'password'))
app.get('/auth', (req, res) => {
res.redirect('/index.html')
})
exports.app = functions.https.onRequest(app)
filepath: public/index.html
Hello Firebase!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.