実現したいこと
firebaseでメールアドレスでの認証機能をWEBサイトに実装したい
発生している現象
メールアドレス・パスワードを入力しログインに成功後、リダイレクト先のURLへ飛ばない
試したこととのその結果
いくつかのコードが重複していたので、そちらを削除した結果、404エラーは出なくなりましたが、リダイレクト先のURLへ飛ばないことは変わっていない状況です。
変更後のソースコード
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>HERE MAP</title> <script src="https://www.gstatic.com/firebasejs/4.10.1/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/4.10.1/firebase-auth.js"></script> <script src="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.js"></script> <link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.css" /> <!-- Initialize Firebase --> <script> var config = { apiKey: "xxx", authDomain: "yyy.firebaseapp.com", databaseURL: "https://yyy.firebaseio.com", projectId: "yyy", storageBucket: "yyy.appspot.com", //messagingSenderId: "sender-id", //appID: "zzz", }; firebase.initializeApp(config); var ui = new firebaseui.auth.AuthUI(firebase.auth()); var uiConfig = { callbacks: { signInSuccessWithAuthResult: function(authResult, redirectUrl) { // User successfully signed in. // Return type determines whether we continue the redirect automatically // or whether we leave that to developer to handle. return true; }, uiShown: function() { // The widget is rendered. // Hide the loader. document.getElementById('loader').style.display = 'none'; } }, // Will use popup for IDP Providers sign-in flow instead of the default, redirect. signInFlow: 'popup', signInSuccessUrl: 'https://www.nikkei.com/', signInOptions: [ // Leave the lines as is for the providers you want to offer your users. firebase.auth.EmailAuthProvider.PROVIDER_ID, ], }; // FirebaseUI描画 ui.start('#firebaseui-auth-container', uiConfig); </script> </head> <body> <div id="firebaseui-auth-container"></div> <script src="https://www.gstatic.com/firebasejs/5.8.1/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/5.8.1/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/ui/3.5.2/firebase-ui-auth__ja.js"></script> <script> ui.start('#firebaseui-auth-container', uiConfig); </script> </body> </html>
エラーメッセージ
検証ツールで見ると以下のようなエラーが出ていました。
firebaseのURLがlocalhostになってしまっている?ようなのでこちらが原因なのでしょうか。
login.html:14 GET http://localhost/__/firebase/5.3.1/firebase-app.js net::ERR_ABORTED 404 (Not Found) login.html:73 GET http://localhost/config.js net::ERR_ABORTED 404 (Not Found) login.html:121 GET http://localhost/__/firebase/7.15.5/firebase-app.js net::ERR_ABORTED 404 (Not Found) login.html:125 GET http://localhost/__/firebase/7.15.5/firebase-analytics.js net::ERR_ABORTED 404 (Not Found) login.html:16 GET http://localhost/__/firebase/init.js net::ERR_ABORTED 404 (Not Found) login.html?mode=select:15 GET http://localhost/__/firebase/5.3.1/firebase-auth.js net::ERR_ABORTED 404 (Not Found) login.html?mode=select:73 GET http://localhost/config.js net::ERR_ABORTED 404 (Not Found) login.html?mode=select:83 Uncaught SyntaxError: Unexpected token ']' logger.ts:86 [2020-07-05T08:11:06.763Z] @firebase/app: Warning: Firebase is already defined in the global scope. Please make sure Firebase library is only loaded once. l @ firebase-app.js:1 e.warn @ firebase-app.js:1 (anonymous) @ firebase-app.js:1 (anonymous) @ firebase-app.js:1 (anonymous) @ firebase-app.js:1 login.html?mode=select:121 GET http://localhost/__/firebase/7.15.5/firebase-app.js net::ERR_ABORTED 404 (Not Found) login.html?mode=select:125 GET http://localhost/__/firebase/7.15.5/firebase-analytics.js net::ERR_ABORTED 404 (Not Found) login.html?mode=select:128 GET http://localhost/__/firebase/init.js net::ERR_ABORTED 404 (Not Found)
ソースコード
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>HERE MAP</title> <script src="https://www.gstatic.com/firebasejs/4.10.1/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/4.10.1/firebase-auth.js"></script> <script src="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.js"></script> <link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.css" /> <script defer src="/__/firebase/5.3.1/firebase-app.js"></script> <script defer src="/__/firebase/5.3.1/firebase-auth.js"></script> <script defer src="/__/firebase/init.js"></script> <!-- Initialize Firebase --> <script src="/__/firebase/init.js"></script> <script> var config = { apiKey: "xxx", authDomain: "yyy.firebaseapp.com", databaseURL: "https://yyy.firebaseio.com", projectId: "yyy", storageBucket: "yyy.appspot.com", //messagingSenderId: "sender-id", //appID: "", }; firebase.initializeApp(config); var ui = new firebaseui.auth.AuthUI(firebase.auth()); var uiConfig = { callbacks: { signInSuccessWithAuthResult: function(authResult, redirectUrl) { // User successfully signed in. return true; }, uiShown: function() { // The widget is rendered. // Hide the loader. document.getElementById('loader').style.display = 'none'; } }, // Will use popup for IDP Providers sign-in flow instead of the default, redirect. signInFlow: 'popup', signInSuccessUrl: 'https://www.nikkei.com/', signInOptions: [ // Leave the lines as is for the providers you want to offer your users. firebase.auth.EmailAuthProvider.PROVIDER_ID, ], }; // FirebaseUI描画 ui.start('#firebaseui-auth-container', uiConfig); </script> </head> <body> <div id="firebaseui-auth-container"></div> <script src="https://www.gstatic.com/firebasejs/5.8.1/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/5.8.1/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/ui/3.5.2/firebase-ui-auth__ja.js"></script> <script src="./config.js"></script> <script> ui.start('#firebaseui-auth-container', uiConfig); </script> <div class="inputform"> <form action="geocode.php" method="get"> <input type="text" name="address"> <input type="submit" value="検索"> </form> </div> <!-- Insert these scripts at the bottom of the HTML, but before you use any Firebase services --> <!-- Firebase App (the core Firebase SDK) is always required and must be listed first --> <script src="https://www.gstatic.com/firebasejs/6.2.0/firebase-app.js"></script> <!-- Add Firebase products that you want to use --> <script src="https://www.gstatic.com/firebasejs/6.2.0/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/6.2.0/firebase-firestore.js"></script> <!-- Previously loaded Firebase SDKs --> <!-- The core Firebase JS SDK is always required and must be listed first --> <script src="/__/firebase/7.15.5/firebase-app.js"></script> <!-- TODO: Add SDKs for Firebase products that you want to use https://firebase.google.com/docs/web/setup#available-libraries --> <script src="/__/firebase/7.15.5/firebase-analytics.js"></script> <!-- Initialize Firebase --> <script src="/__/firebase/init.js"></script> </body> </html>
試したこと
エラーメッセージでの検索
あなたの回答
tips
プレビュー