I'm attempting to use the `user` query to get data...
# prisma-whats-new
d
I'm attempting to use the
user
query to get data for the currently logged in user. When my app renders on the server the user and data are present but when it renders on the client the user is
null
. It seems other queries are working as expected. Any ideas what my issue could be? Thanks!
n
sounds like your token is not present on the client
d
A mistake I made once was the token I used to configure Apollo
Copy code
networkInterface.use([{
  applyMiddleware (req, next) {
    if (!req.options.headers) {
      req.options.headers = {}
    }
    // get the authentication token from local storage if it exists
    if (localStorage.getItem('auth0IdToken')) {
      req.options.headers.authorization = `Bearer ${localStorage.getItem('auth0IdToken')}`
    }
    next()
  }
}])
Was not the same token I was setting in local storage:
Copy code
window.localStorage.setItem('diffAuth0IdToken', authResult.idToken)
It caused no errors - user was just always
null
d
Thanks for the replies. That's interesting. But if that were the case wouldn't user also be
null
when rendered on the server? That's the weird thing is I can see the correct props when I log them server-side.
Also, is it normal for queries to always be executed server and client side when doing ssr? Almost seems like my store is not hydrating correctly...
ooooohhhhhhh 😬 I simply wasn't setting the auth header client side. Thanks for pointing me in the right direction @nilan @doug_w. I still don't understand why those queries are being run both server and client side though.