awinogrodzki/next-firebase-auth-edge

customToken is undefined

Closed this issue · 1 comments

Hello, I've been using the library for a couple of weeks and everything was working well. I was using the customToken option to allow me to use the firebase SDK. I logged out and then logged back in to test the login page and now customToken is always undefined. I've removed everything from the app so it's literally just the login page now and I just can't get it to retrieve a value. I haven't touched any config in the middleware. It should just work shouldn't it? Everything else is there, my tokens, claims etc and all other functionality is fine. Any idea what would cause it to now be undefined?

Found the issue, very painful but I'm putting it here for anyone else.

My options in authConfig were missing enableCustomToken. So although it was in my middleware config, it was missing here.

await refreshCookiesWithIdToken(idToken, await headers(), await cookies(), authConfig);

I'm using the server action approach to logging in.