質問編集履歴
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,6 +3,46 @@
|
|
3
3
|
実装の内容としては以下リンクにあるような「basic-auth-connect」を用いたものです。
|
4
4
|
[https://gist.github.com/mkamakura/c7a57bd1bf64b017f180573adf8ba3d8](https://gist.github.com/mkamakura/c7a57bd1bf64b017f180573adf8ba3d8)
|
5
5
|
|
6
|
+
|
7
|
+
```json
|
8
|
+
{
|
9
|
+
"hosting": {
|
10
|
+
"public": "build",
|
11
|
+
"ignore": [
|
12
|
+
"firebase.json",
|
13
|
+
"**/.*",
|
14
|
+
"**/node_modules/**"
|
15
|
+
],
|
16
|
+
"redirects": [{
|
17
|
+
"source": "/",
|
18
|
+
"destination": "/auth"
|
19
|
+
}],
|
20
|
+
"rewrites": [
|
21
|
+
{
|
22
|
+
"source": "**",
|
23
|
+
"function": "app"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
```
|
30
|
+
```node
|
31
|
+
const functions = require('firebase-functions')
|
32
|
+
const express = require('express')
|
33
|
+
const basicAuth = require('basic-auth-connect')
|
34
|
+
|
35
|
+
const app = express()
|
36
|
+
|
37
|
+
app.use(basicAuth('username', 'password'))
|
38
|
+
|
39
|
+
app.get('/auth', (req, res) => {
|
40
|
+
res.redirect('/index.html')
|
41
|
+
})
|
42
|
+
|
43
|
+
exports.app = functions.https.onRequest(app)
|
44
|
+
```
|
45
|
+
|
6
46
|
firebaseのfunctionsのコンソールからログを確認してみると、そもそもリダイレクトしてfunctionsの関数を通っていないようなのですが、ルーティング処理が上手くいないのは何が原因なのでしょうか。
|
7
47
|
|
8
48
|
よろしくお願いいたします。
|
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Firebase Hostingを用い、React(ルーティングにはreact-router-domを使用)にてWEBアプリを公開しようとしています。basic認証を行いたいのですが、index.htmlを起点としたSPAなので、cloud functionsを通してルーティング処理をしようとしていますが、うまくいきません。
|
2
2
|
|
3
3
|
実装の内容としては以下リンクにあるような「basic-auth-connect」を用いたものです。
|
4
|
-
https://gist.github.com/mkamakura/c7a57bd1bf64b017f180573adf8ba3d8
|
4
|
+
[https://gist.github.com/mkamakura/c7a57bd1bf64b017f180573adf8ba3d8](https://gist.github.com/mkamakura/c7a57bd1bf64b017f180573adf8ba3d8)
|
5
5
|
|
6
6
|
firebaseのfunctionsのコンソールからログを確認してみると、そもそもリダイレクトしてfunctionsの関数を通っていないようなのですが、ルーティング処理が上手くいないのは何が原因なのでしょうか。
|
7
7
|
|