Search code examples
firebasewebpackfirebase-app-check

Firebase AppCheck gives 'appCheck is not a function' when using the client SDK


I'm getting an error when I initialize the AppCheck in my project.

Firebase version: "^8.8.1".

Here is my configuration file:

import firebase from "firebase/app";
import "firebase/functions";

const firebaseConfig = {
    apiKey: "--",
    authDomain: "--",
    projectId: "--",
    storageBucket: "--",
    messagingSenderId: "--",
    appId: "--"
};

const check = firebase.appCheck() // here is the error
check.activate('appCheckKey', true)

const app = firebase.initializeApp(firebaseConfig)
const functions = firebase.functions()

export {
    app,
    functions
}

Note that I'm using dummy data here since keys are sensitive information.

This is the error that I get from Webpack:

firebase.js?dc59:13 Uncaught TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_0__.default.appCheck is not a function
    at eval (firebase.js?dc59:13)
    at Module../src/firebase.js (app.js:1173)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (SorteoForm.vue?0e40:55)
    at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader-v16/dist/index.js?!./src/components/SorteoForm.vue?vue&type=script&lang=js (app.js:938)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (SorteoForm.vue?a886:1)
    at Module../src/components/SorteoForm.vue?vue&type=script&lang=js (app.js:1149)

Any idea what could be? Thanks!


Solution

  • You need to import app check similar to Firestore and functions.

    import firebase from "firebase/app";
    import "firebase/functions";
    import 'firebase/app-check';
    // Import app-check ^
    
    
    const check = firebase.appCheck();
    check.activate('appCheckKey', true);