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
43 stars 9 forks source link

added a configurable WORKOS_COOKIE_NAME optional env var #59

Open mattbf opened 1 week ago

mattbf commented 1 week ago

Fixes issue #58

Right now, if you set a cookie on your backend and try to use AuthKit with nextjs on your frontend, it will not work unless you set the cookieName to "wos-session".

This would allow users who are integrating with workOS in a full stack application to customize the cookieName used. For example, in a nodejs backend:

res.cookie("myapp-session", encryptedSession, {
  path: "/",
  httpOnly: true,
  secure: true,
  sameSite: "lax",
});

Then you would set the optional env var WORKOS_COOKIE_NAME on the frontend and AuthKit would automatically and properly consume the cookie 🍪 😄