I’m trying to configure AppCheck in my web app (using SvelteKit).
I’ve registered my web app with recaptcha and then Added this basic code:
onMount(async () => {
const appCheck = initializeAppCheck(app, {
provider: new ReCaptchaV3Provider('my-key'),
isTokenAutoRefreshEnabled: true
})
})
But it fails with 400 error. Those occur because the POST request has ‘unknown’ where the Recaptcha (and firebase collection) should be.
POST URL: https://content-firebaseappcheck.googleapis.com/v1/projects/undefined/apps/undefined:exchangeRecaptchaV3Token?key=undefined
Why does it happen? how can I fix it?
*The only similar case is here, but it has no solution, and might not be the same.
2
Answers
SOLVED: The request was malformed due to mistaken firebaseConfig data.
Make sure your firebaseConfig object has all the details as specified in the Firebase console under the app.
Then do the following
And make sure your imports look like this
The issue I think is due to the Firebase AppCheck guide specifying using
Removing the
{}
prevents the issue and the app config data can be properly accessed buy the initializeAppCheck method.Hope this helps!