cloudflare / turnstile-firebase-app-check

MIT License
4 stars 1 forks source link

Firebase function not being called #8

Open andrevferreiraa opened 3 weeks ago

andrevferreiraa commented 3 weeks ago

Hey guys,

I'm trying to set up turnstile app check on a Nuxt3 project. Already installed the extension, function is online and working. But it is never called by the plugin. HTTP_ENDPOINT is correct, but i see in the docs this format:

'${function:function-name.url}'

Made me wonder if i'm passing the http endpoint correctly.

import { CloudflareProviderOptions } from '@cloudflare/turnstile-firebase-app-check'
import { initializeAppCheck, CustomProvider } from 'firebase/app-check'
import { getFunctions } from 'firebase/functions'

export default defineNuxtPlugin((nuxtApp) => {
  if (!process.client) return
  const firebaseApp = nuxtApp.vueApp.$nuxt.$firebaseApp
  const turnstileSiteKey = process.env.TURNSTILE_KEY
  const region = getFunctions(firebaseApp).region
  const HTTP_ENDPOINT = `https://${region}-${firebaseApp.options.projectId}.cloudfunctions.net/ext-cloudflare-turnstile-app-check-provider-tokenExchange`

  const cpo = new CloudflareProviderOptions(HTTP_ENDPOINT, turnstileSiteKey)
  const provider = new CustomProvider(cpo)

  initializeAppCheck(firebaseApp, { provider })
})
andrevferreiraa commented 3 weeks ago

EDIT: Function is actually being called now, but getting a 500 Internal server error in the response