-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit frequency of calls to set auth cookie (optimization) #424
Comments
Thanks for the issue. Agreed, this could be a nice optimization. What Firebase JS SDK API would work for this? If we implement this, we'd want logic to ensure a cookie is set in the case it's not set (e.g., cookies were cleared) even if the ID token has not changed. |
Generally I don't undesrtand why now firebase.auth().onIdTokenChanged is called on every page. It is a big issue because when we call this operation request to backend is happened and then request to firebase, more requests = more money to pay. |
The Firebase I agree, most apps would work well while reducing the calls to the login endpoint. The question is how to implement it. Really, we don't care about refreshing the cookie when the ID token will expire but rather sometime before the auth cookie (refresh token) will expire. Ex: if the auth cookie has a max age of 12 days, maybe the app wants to refresh it after 5 days—and don't call the login endpoint for those first 5 days. Right now, the client side has no visibility into whether the auth cookie is set because the cookie is http-only. One approach is to set a separate JS-accessible cookie with the Thoughts? |
I think it could be better to save token expieartion date in JS-accessible cookie instead of last login time. |
Is there any news on this subject? I get a call on every request to the login endpoint and it's really not ideal IMHO |
onIdTokenChange
function is called one every page
Describe the bug
When you visit any page,
onIdTokenChange
function is called, so the token is changed.I think this is redudant, we don't need to do update token on every page.
Versions
next-firebase-auth version: ^0.14.1-alpha.0,
Firebase JS SDK: 8.10.0
Next.js: 12.0.8
To Reproduce
Steps to reproduce the behavior:
withAuthUser
Completed auth API request via tokenChangedHandler.
Expected behavior
Should be called only when token expired or user auth state changed.
The text was updated successfully, but these errors were encountered: