Problems:
I get the error below when I tried to login using firebase auth. Everything is fine when I login using firebase auth emulator, but it presents error when using without using the auth emulator. I have also received a 500 response from login API endpoint: {"error":"Unexpected error."}
from browser console, which I presume the error is highly related with next-firebase-auth.
FirebaseAuthError: `uid` argument must be a non-empty string uid.
at FirebaseAuthError.FirebaseError [as constructor] (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\firebase-admin\lib\utils\error.js:44:28)
at FirebaseAuthError.PrefixedFirebaseError [as constructor] (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\firebase-admin\lib\utils\error.js:90:28)
at new FirebaseAuthError (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\firebase-admin\lib\utils\error.js:149:16)
at FirebaseTokenGenerator.createCustomToken (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\firebase-admin\lib\auth\token-generator.js:101:19)
at Auth.BaseAuth.createCustomToken (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\firebase-admin\lib\auth\base-auth.js:87:36)
at D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\next-firebase-auth\build\index.node.js:2:22240
at Generator.next (<anonymous>)
at asyncGeneratorStep (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
at _next (D:\Alston\Programming\Personal-Project\netflix-clone\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
errorInfo: {
code: 'auth/argument-error',
message: '`uid` argument must be a non-empty string uid.'
},
codePrefix: 'auth'
}
I have set up my /api/login
page exactly as the official example. I have tried using signInWithEmailAndPassword
and signInWithPopup
(which using Google to authenticate), both did success to login as console.log(results)
shows the user credentials and I can also find the relevant data in indexed DB
too.
Versions of the packages
"next-firebase-auth": "^1.0.0-canary.5"
"firebase-admin": "^10.0.2",
"firebase": "^9.6.1",
The main issues was with login page, and here's the Github Repo.
CodePudding user response:
I finally found the solution on github, remove the FIREBASE_AUTH_EMULATOR_HOST=localhost:9099
in your .env.local
file, and everythings is back on track again, what a weird problem.