@firebase/app-check: AppCheck: Requests throttled due to 400 error. Attempts allowed again after 00m:01s (appCheck/throttled)

Viewed 57

I have just set up my app and integrated appcheck and the code looks like

import { initializeApp, getApps } from "firebase/app";
import { getAuth, } from "firebase/auth";
import { getAnalytics } from "firebase/analytics";
import {  getFirestore } from "firebase/firestore";

let app;

if (!getApps().length) {
    app = initializeApp({
        apiKey: process.env.NEXT_PUBLIC_API_KEY,
        authDomain: process.env.NEXT_PUBLIC_AUTH_DOMAIN,
        projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
        storageBucket: process.env.NEXT_PUBLIC_STORAGE_BUCKET,
        databaseURL: process.env.NEXT_PUBLIC_DATABASE_URL,
        messagingSenderId: process.env.NEXT_PUBLIC_MESSAGING_ID,
        appId: process.env.NEXT_PUBLIC_APP_ID,
    });
}
   async function initialize() {
    const { initializeApp } = require("firebase/app");
    const { initializeAppCheck, ReCaptchaV3Provider } = require("firebase/app-check");
  
    const app = initializeApp({
        apiKey: process.env.NEXT_PUBLIC_API_KEY,
        authDomain: process.env.NEXT_PUBLIC_AUTH_DOMAIN,
        projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
        storageBucket: process.env.NEXT_PUBLIC_STORAGE_BUCKET,
        databaseURL: process.env.NEXT_PUBLIC_DATABASE_URL,
        messagingSenderId: process.env.NEXT_PUBLIC_MESSAGING_ID,
        appId: process.env.NEXT_PUBLIC_APP_ID,
    });
    return initializeAppCheck(app, {
      provider: new ReCaptchaV3Provider(process.env.NEXT_PUBLIC_APP_CHECK_KEY),
      isTokenAutoRefreshEnabled: true
    });
  }
  
  if (typeof window !== "undefined") {
    initialize().then((res)=>{
       // console.log(res)
    }).catch((err)=>{
        throw(err)
    })
   
 }


export const auth = getAuth();
export const db = getFirestore();
export default app;

So when i set isTokenAutoRefreshEnabled to true, the error comes up and when I set it to false everything works. I am using firebase ^9.9.4 and this gives the above error so I decided to downgrade and use firebase ^9.8.2 since I had set up a different project the same way and there were no errors. In this version, I get the error

FirebaseError: AppCheck: Fetch server returned an HTTP error status. HTTP status: 400. (appCheck/fetch-status-error).
    at exchangeToken

What is this error and how can I fix it

0 Answers
Related