nuxt-auth icon indicating copy to clipboard operation
nuxt-auth copied to clipboard

`getServerSession` is broken using local provider

Open FrankoFM opened this issue 1 year ago • 1 comments

Environment

0.8.0

Reproduction

More or less following the playground-local

Describe the bug

When using getServerSession it always results in a 500 Error with the message:

Tried to get server session without setting up an endpoint to handle authentication (see https://github.com/sidebase/nuxt-auth#quick-start)

Additional context

I currenly dont have the time to dive deeper into this, but thats what I found: getServerSession is defined here It will check for preparedAuthHandler, followed by a fetch, then checking again, without ever setting the value, so it has to result in said error.

Logs

No response

FrankoFM avatar Jul 17 '24 09:07 FrankoFM

I also noticed that the /session endpoint is hardcoded here, but it should use the value defined in the nuxt config.

FrankoFM avatar Jul 17 '24 09:07 FrankoFM

getServerSession is not supported by the local or refresh providers at the moment, as the local and refresh providers were built to also support static deployments, which is why they placed a focus on client-side interactions.

There is currently an open issue (https://github.com/sidebase/nuxt-auth/issues/854) and PR (https://github.com/sidebase/nuxt-auth/pull/855) that aims to add getServerSession and getToken to the local and refresh providers. You can follow along with the process in these two places!

zoey-kaiser avatar Aug 11 '24 13:08 zoey-kaiser