workos / authkit-nextjs

The WorkOS library for Next.js provides convenient helpers for authentication and session management using WorkOS & AuthKit with Next.js.
MIT License
66 stars 19 forks source link

cannot access session info on server routes #131

Open sr0m opened 6 days ago

sr0m commented 6 days ago

Describe the bug I have a default middleware setup. a getSession works fine on client components, but it appears that the cookie is not available on calls from server routes.

middleware

import { authkitMiddleware } from "@workos-inc/authkit-nextjs";
export default authkitMiddleware();
export const config = {
  matcher: ['/dashboard', '/employees', '/organization', '/time'],
}

session lookup:


export async function GET(request: Request) {

  const session = await getSession();
    console.log("session:", session);
  }

calls from a client component work correctly: It appears that a call from a server route does not have access to the wos_session cookie? (prints { user: null } )

PaulAsjes commented 3 days ago

Hey there, I'm unable to recreate this locally. Which route are you hitting that evokes the session lookup?