그래서 나는 이것 다음 온라인 튜터리얼을 구축하는 방법에 대한 미을 구축 및 실행으로 이 문제를 해결합니다.
import "../styles/globals.css";
import { useAuthState } from "react-firebase-hooks/auth";
import { auth, db } from "../firebase";
function MyApp({ Component, pageProps }) {
const [user] = useAuthState(auth);
if (!user) return <Login />;
return <Component {...pageProps} />;
}
export default MyApp;
이것은 나 firebase.js,제거했 내 apikey 가이기 때문에 나는 나의 코드 그러나 하는 생각하지 않는 문제가 발생했을 수도 있습니다.
import firebase from "firebase/app";
const firebaseConfig = {
apiKey: "",
authDomain: "global-chat-80ab3.firebaseapp.com",
projectId: "global-chat-80ab3",
storageBucket: "global-chat-80ab3.appspot.com",
messagingSenderId: "405392556419",
appId: "1:405392556419:web:562d012b108561b8be76b6",
};
const app = !firebase.apps.length
? firebase.initializeApp(firebaseConfig)
: firebase.app();
const db = app.firestore();
const auth = app.auth();
const provider = new firebase.auth.GoogleAuthProvider();
export { db, auth, provider };