From 23cd41bd4876d86da29bbe9e2f6d3ce4dc7ceaf3 Mon Sep 17 00:00:00 2001 From: Rakantor Date: Mon, 24 Oct 2022 15:14:26 +0200 Subject: [PATCH] Integrate Firebase App Check --- nuxt.config.js | 4 ++++ plugins/firebase.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/nuxt.config.js b/nuxt.config.js index 9c1137f..2099e76 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -57,6 +57,10 @@ export default { middleware: 'auth' }, + env: { + firebaseAppCheckDebugToken: process.env.NODE_ENV !== 'production' + }, + // Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify vuetify: { customVariables: ['~/assets/variables.scss'], diff --git a/plugins/firebase.js b/plugins/firebase.js index c4a6971..5727d06 100644 --- a/plugins/firebase.js +++ b/plugins/firebase.js @@ -1,6 +1,7 @@ import { initializeApp } from 'firebase/app' import { getAuth } from 'firebase/auth' import { getFirestore } from 'firebase/firestore' +import { initializeAppCheck, ReCaptchaV3Provider } from 'firebase/app-check' // Firebase configuration const firebaseConfig = { @@ -15,6 +16,14 @@ const firebaseConfig = { // Initialize Firebase const app = initializeApp(firebaseConfig) +// Initialize Firebase App Check +self.FIREBASE_APPCHECK_DEBUG_TOKEN = process.env.firebaseAppCheckDebugToken +initializeAppCheck(app, { + provider: new ReCaptchaV3Provider('6LcrDqoiAAAAALVT6mjDGTj8EMjukfkQJqxnZ2SA'), + // Optional argument. If true, the SDK automatically refreshes App Check tokens as needed. + isTokenAutoRefreshEnabled: true +}) + // Initialize Firebase Authentication and get a reference to the service const auth = getAuth(app)