не работает авторизация через firebase ,auth/network-request-failed

не работает авторизация через firebase,просто так перестало подключаться. Получается все время приходит null в user.Ошибка code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred.", a: null. Сам файл firebase

import firebase from 'firebase/app'
import 'firebase/auth'


const app = firebase.initializeApp({
    apiKey: "AIzaSyB4WZtonY9FYW_C59m7j3eNjZo_shoSghc",
    authDomain: "auth-shop-2f7f0.firebaseapp.com",
    databaseURL: "https://auth-shop-2f7f0-default-rtdb.europe-west1.firebasedatabase.app",
    projectId: "auth-shop-2f7f0",
    storageBucket: "auth-shop-2f7f0.appspot.com",
    messagingSenderId: "353077909849",
    appId: "1:353077909849:web:d2f67e03ba00269228d448"
}
)
export const auth = app.auth()
export default app 

Где происходит сам запрос,доходит до этого момента auth.signOut() или любого с auth.

import React, { useContext, useState, useEffect } from "react"
import { auth } from "../../firebase";

const AuthContext = React.createContext()

export function useAuth() {
  return useContext(AuthContext)
}

export function AuthProvider({ children,setLoadingg }) {
  const [currentUser, setCurrentUser] = useState()
  const [loading, setLoading] = useState(true)

  function signup(email, password) {
    return auth.createUserWithEmailAndPassword(email, password)
  }

  function login(email, password) {
    setLoadingg(true)
    return auth.signInWithEmailAndPassword(email, password)
  }

  function logout() {
    setLoadingg(false)
    return auth.signOut()
  }

  function resetPassword(email) {
    return auth.sendPasswordResetEmail(email)
  }

  function updateEmail(email) {
    return currentUser.updateEmail(email)
  }

  function updatePassword(password) {
    return currentUser.updatePassword(password)
  }

  useEffect(() => {
    const unsubscribe = auth.onAuthStateChanged(user => {
      setCurrentUser(user)
      setLoading(false)
    })

    return unsubscribe
  }, [])

  const value = {
    currentUser,
    login,
    signup,
    logout,
    resetPassword,
    updateEmail,
    updatePassword
  }

  return (
    <AuthContext.Provider value={value}>
      {!loading && children}
    </AuthContext.Provider>
  )
}

Login

import React, { useRef, useState } from "react"
import { Form, Button, Card, Alert } from "react-bootstrap"
import { useAuth } from "./AuthContext";
import { Link, useHistory } from "react-router-dom"

export default function Login({cart}) {
    const emailRef = useRef()
    const passwordRef = useRef()
    const { login } = useAuth()
    const [error, setError] = useState("")
    const [loading, setLoading] = useState(false)
    const history = useHistory()
  
    async function handleSubmit(e) {
      e.preventDefault()
      try {
        setError("")
        setLoading(true)
        await login(emailRef.current.value, passwordRef.current.value)
        cart>0?history.push("/Cart"):history.push("/Shop")
       
      } catch {
        setError("Failed to log in")
      }
  
      setLoading(false)
    }
  
    return (
      <>
        <Card>
          <Card.Body>
            <h2 className="text-center mb-4">Log In</h2>
            {error && <Alert variant="danger">{error}</Alert>}
            <Form onSubmit={handleSubmit}>
              <Form.Group id="email">
                <Form.Label>Email</Form.Label>
                <Form.Control type="email" ref={emailRef} required />
              </Form.Group>
              <Form.Group id="password">
                <Form.Label>Password</Form.Label>
                <Form.Control type="password" ref={passwordRef} required />
              </Form.Group>
              <Button disabled={loading} className="w-100" type="submit">
                Log In
              </Button>
            </Form>
            <div className="w-100 text-center mt-3">
              <Link to="/forgot-password">Forgot Password?</Link>
            </div>
          </Card.Body>
        </Card>
        <div className="w-100 text-center mt-2">
          Need an account? <Link to="/signup">Sign Up</Link>
        </div>
      </>
    )
  }

Ответы (0 шт):