teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

試してみたことの記載

2020/07/06 00:36

投稿

dbrow
dbrow

スコア18

title CHANGED
@@ -1,1 +1,1 @@
1
- firebaseの認証機能実装中エラー( ERR_ABORTED 404)
1
+ firebaseの認証機能でログイン成功後、リダイレクト先URLに飛ばない
body CHANGED
@@ -4,6 +4,86 @@
4
4
  ### 発生している現象
5
5
  メールアドレス・パスワードを入力しログインに成功後、リダイレクト先のURLへ飛ばない
6
6
 
7
+ ### 試したこととのその結果
8
+ いくつかのコードが重複していたので、そちらを削除した結果、404エラーは出なくなりましたが、リダイレクト先のURLへ飛ばないことは変わっていない状況です。
9
+
10
+ ### 変更後のソースコード
11
+ ```ここに言語を入力
12
+ <!DOCTYPE html>
13
+ <html lang="ja">
14
+
15
+ <head>
16
+ <meta charset="utf-8">
17
+ <title>HERE MAP</title>
18
+
19
+ <script src="https://www.gstatic.com/firebasejs/4.10.1/firebase-app.js"></script>
20
+ <script src="https://www.gstatic.com/firebasejs/4.10.1/firebase-auth.js"></script>
21
+
22
+ <script src="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.js"></script>
23
+ <link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.css" />
24
+
25
+ <!-- Initialize Firebase -->
26
+ <script>
27
+ var config = {
28
+ apiKey: "xxx",
29
+ authDomain: "yyy.firebaseapp.com",
30
+ databaseURL: "https://yyy.firebaseio.com",
31
+ projectId: "yyy",
32
+ storageBucket: "yyy.appspot.com",
33
+ //messagingSenderId: "sender-id",
34
+ //appID: "zzz",
35
+ };
36
+ firebase.initializeApp(config);
37
+
38
+
39
+ var ui = new firebaseui.auth.AuthUI(firebase.auth());
40
+
41
+ var uiConfig = {
42
+ callbacks: {
43
+ signInSuccessWithAuthResult: function(authResult, redirectUrl) {
44
+ // User successfully signed in.
45
+ // Return type determines whether we continue the redirect automatically
46
+ // or whether we leave that to developer to handle.
47
+ return true;
48
+ },
49
+ uiShown: function() {
50
+ // The widget is rendered.
51
+ // Hide the loader.
52
+ document.getElementById('loader').style.display = 'none';
53
+ }
54
+ },
55
+ // Will use popup for IDP Providers sign-in flow instead of the default, redirect.
56
+ signInFlow: 'popup',
57
+ signInSuccessUrl: 'https://www.nikkei.com/',
58
+ signInOptions: [
59
+ // Leave the lines as is for the providers you want to offer your users.
60
+ firebase.auth.EmailAuthProvider.PROVIDER_ID,
61
+ ],
62
+ };
63
+
64
+ // FirebaseUI描画
65
+ ui.start('#firebaseui-auth-container', uiConfig);
66
+
67
+ </script>
68
+
69
+ </head>
70
+
71
+ <body>
72
+
73
+ <div id="firebaseui-auth-container"></div>
74
+ <script src="https://www.gstatic.com/firebasejs/5.8.1/firebase-app.js"></script>
75
+ <script src="https://www.gstatic.com/firebasejs/5.8.1/firebase-auth.js"></script>
76
+ <script src="https://www.gstatic.com/firebasejs/ui/3.5.2/firebase-ui-auth__ja.js"></script>
77
+ <script>
78
+ ui.start('#firebaseui-auth-container', uiConfig);
79
+ </script>
80
+
81
+ </body>
82
+
83
+ </html>
84
+ ```
85
+
86
+
7
87
  ### エラーメッセージ
8
88
  検証ツールで見ると以下のようなエラーが出ていました。
9
89
  firebaseのURLがlocalhostになってしまっている?ようなのでこちらが原因なのでしょうか。