I can successfully enable App Check for my Firebase Functions and they are working as expected when I deploy them to the Firebase server. However, when I try to test with Firebase emulator, the functions with App Check will return unauthenticated error.
How can I make the emulator return a valid response? Is there any way like adding the debug token in the emulator, like the Firebase console?
2
Answers
The trick here is to turn off App Check when the functions is running on emulator. This can be achieve by checking the environment variable FUNCTIONS_EMULATOR.
As per my undestanding base on this post. The use of the app check using local emulators is not possible. This is presumably because localhost is not listed as an allowed domain, resulting in unathenticated error.
A workaround was recommended on the same post. Another user successfully set up app check by adding this snippet right above the call to activate appCheck.
Hope this will help you on your use case. for more information you can check the orginal post.