Skip to content

Instantly share code, notes, and snippets.

@mkamakura
Created December 17, 2017 03:35
Show Gist options
  • Save mkamakura/c7a57bd1bf64b017f180573adf8ba3d8 to your computer and use it in GitHub Desktop.
Save mkamakura/c7a57bd1bf64b017f180573adf8ba3d8 to your computer and use it in GitHub Desktop.
[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