-
-
Save nabettu/45d014a14de724e256c9c02cffc0281f to your computer and use it in GitHub Desktop.
[Firebase Hosting,Functions] basic認証付きでサイトを公開する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hosting": { | |
"public": "public", | |
"rewrites": [ | |
{ | |
"source": "**", | |
"function": "app" | |
} | |
], | |
"redirects": [{ | |
"source": "/", | |
"destination": "/auth" | |
}], | |
"ignore": [ | |
"firebase.json", | |
"**/.*", | |
"**/node_modules/**" | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filepath: public/index.html | |
Hello Firebase! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment