`getSession`'s status is always unauthenticated on server-side in route middlewares
See original GitHub issueEnvironment
Nuxi 3.0.0-rc.13 RootDir: /Users/nook/work/tls-interim-front Nuxt project info: (copied to clipboard)
- Operating System:
Darwin
- Node Version:
v18.12.0
- Nuxt Version:
3.0.0-rc.13
- Nitro Version:
0.6.1
- Package Manager:
npm@8.19.2
- Builder:
vite
- User Config:
typescript
,css
,modules
,auth
,build
,googleFonts
,runtimeConfig
- Runtime Modules:
@nuxtjs/tailwindcss@6.1.3
,@nuxtjs/google-fonts@3.0.0-1
,@nuxtjs/svg@0.4.0
,@pinia/nuxt@0.4.3
,floating-vue/nuxt
,@sidebase/nuxt-auth@0.0.1-beta.5
- Build Modules:
-
Reproduction
No response
Describe the bug
Given I am authenticated:
When trying to guard a route, the session is always null (unauthenticated
) on server side, but available on client side
definePageMeta({
middleware: [async () => {
const { status } = await useSession();
console.log(status.value); // 'unauthenticated' on server, 'authenticated' on client
if (status.value === 'authenticated') {
return true;
} else {
console.log('hmm not ok');
console.log(status.value); // 'unauthenticated' on server
}
}],
});
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Laravel sanctum unauthenticated - Stack Overflow
I am using Laravel sanctum in my project with angular as frontend. Getting unauthenticated from the second api request. Please ...
Read more >Is NextAuth middleware enough to secure all pages and APIs?
For context, I'm using Google Auth, and export { default } from "next-auth/middleware" to secure pages / APIs. Whenever a user navigates to...
Read more >ASP.NET Core Middleware | Microsoft Learn
Authentication Middleware (UseAuthentication) attempts to authenticate the user before they're allowed access to secure resources. Authorization ...
Read more >Securing pages and API routes - NextAuth.js
The methods getSession() and getToken() both return an object if a session is valid and null if a session is invalid or has...
Read more >Using API route in inertia + laravel always returns ... - Laracasts
I was able to login using inertia form, but if I use auth:sanctum in my API route middleware, it does not work... it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @noook and @darwebdb (who I know is tracking this for his blog-post https://darweb.nl/blog/article/user-auth-and-session-management-in-nuxt3-with-sidebase-nuxt-auth-and-strapi-v4-1)
v0.1.0 is out now 🎊 It includes isomorphic
useSession
which resolves this issue (: Let me know or open a new issue if something comes up.Use the release as:
hm, I briefly tried it and it threw some other error. I’ll investigate a bit more (: