Open chriscdn opened 9 months ago
Same here ... 2 days, I'm raging against the version trying to find something ! And here is @chriscdn finding the exact same problem !
In my case I changed the base url to baseURL: '/api/admin/auth' and got same problem.
The try catch gave me this information:
statusCode: 500, fatal: false, unhandled: false, statusMessage: 'Tried to get server session without setting up an endpoint to handle authentication (see https://github.com/sidebase/nuxt-auth#quick-start)', data: undefined }
As a workaround I decided to change getServerSession by :
const authBasePath = useRuntimeConfig().public.auth.computed.pathname
const session = await $fetch(authBasePath + '/session', {
method: 'GET',
headers: event.headers
})
It's working fine so far. 🚀
Environment
Build Modules: -
Reproduction
No response
Describe the bug
I created a
/server/api/
set of endpoints for connecting and disconnecting existing social accounts. I placed these files in a directory named/server/api/auth-connect
. In these files, thegetServerSession
returnsundefined
since the api route (/api/auth-connect/
) starts with the string/api/auth
.I traced the problem to the getServerSession method:
In my instance,
authBasePath
resolves to/api/auth
. Sinceevent.path
resolves to/api/auth-connect/
, the check passes and therefore returns null.I can't comment on why this check is necessary, but doubt all routes that start with
auth
should be excluded from using this method.Additional context
No response
Logs
No response