Awaiting current user with Nuxt3 #1557
              
                Unanswered
              
          
                  
                    
                      Cry0nicS
                    
                  
                
                  asked this question in
                Questions and Help
              
            Replies: 1 comment
-
| You can set a session cookie, then the user will already be there SSR. | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Reproduction
I provided a link below to my repository. Not sure how to reproduce with an actual Firebase database...
Steps to reproduce the bug
Using Nuxt3 with SSR and vuefire.
This is what I use on a page - I first await the user, then I load his Collection
Expected behavior
I would expect for the page to first wait until I have a user and then proceed.
Actual behavior
Seems like there's either some sort of race condition or some other sort of issue, where the user is not await.
The middleware (as per the document) deals with
await getCurrentUser()perfectly, but somehow on a Nuxt3 page this doesn't work.It basically throws a 500
Cannot read properties of null (reading 'uid')(on user.uid) or something similar.With a bunch of refreshes, sometimes it works. Most of the time, it doesn't.
Additional information
I don't have a reproduction, since I'm not sure how to provide a connection to Firebase. But here's a permalink to my project where I use exactly that. Link
The reason I want to use
await getCurrentUserinstead ofuseCurrentUseris to avoid all the optional chaining and to... well, only display the page when the user is already loaded.Beta Was this translation helpful? Give feedback.
All reactions