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
67 stars 18 forks source link

added a configurable WORKOS_COOKIE_NAME optional env var #59

Closed mattbf closed 1 month ago

mattbf commented 4 months 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 🍪 😄

PaulAsjes commented 4 months ago

Thanks for this! The code looks good but I'm going to hold on merging this till we figure out a solution for https://github.com/workos/authkit-nextjs/issues/24 and https://github.com/workos/authkit-nextjs/issues/45.

PaulAsjes commented 1 month ago

Released a variation of this in 0.11.0.

mattbf commented 1 month ago

Cheers, thanks @PaulAsjes!