简体   繁体   中英

Firebase AppCheck web app not working in production mode

I cannot get Firebase AppCheck to work in production mode on a Vue.js project with Firestore and Storage. But It works normally in development.

const appCheck: AppCheck = initializeAppCheck(firebaseApp, {
  provider: new ReCaptchaV3Provider(reCaptchaSiteKey),
  isTokenAutoRefreshEnabled: true,
});

getToken(appCheck)
  .then((result: AppCheckTokenResult) => {
    console.log(process.env.NODE_ENV);
    console.log(result.token);
  })
  .catch((e: FirebaseError) => {
    console.log(process.env.NODE_ENV);
    console.log(e.code + ": " + e.message);
  });

In Development mode , using vite, get the token back: 在开发模式

In Production mode , with firebase serve, get appCheck/fecth-status-error: 在此处输入图像描述

Firebaser here!

The error you are receiving is due to the App Check backend not being able to verify the underlying reCAPTCHA attestation.

Things to check for:

  • is reCAPTCHA providing a valid attestation and not somehow thinking your device is a bot?
  • does the site secret uploaded to App Check for this App match the client ID you are using in the App?

If you are using a Debug Token in your development build, that might explain why that one is succeeding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM