awinogrodzki / next-firebase-auth-edge

Next.js Firebase Authentication for Edge and Node.js runtimes. Compatible with latest Next.js features.
https://next-firebase-auth-edge-docs.vercel.app/
MIT License
468 stars 42 forks source link

`refreshServerCookies` ignores cookie settings #236

Closed Onxi95 closed 3 weeks ago

Onxi95 commented 3 weeks ago

Hi! Thanks for creating this awesome library - without it, implementing Firebase in our Next.js app dir project would have taken much longer! :muscle:

Link to the code that reproduces this issue

https://github.com/awinogrodzki/next-firebase-auth-edge/compare/main...Onxi95:next-firebase-auth-edge:main

To Reproduce

https://github.com/user-attachments/assets/3d09eb44-1548-4bf6-9bba-5816417af905

As you can see in the video, cookie settings are ignored by refreshServerCookies

Version

"next-firebase-auth-edge": "^1.7.0-canary.2",

:mag_right: Hypothesis

It looks like the parameters for setting cookies are missing in this part.

export function appendCookie(
  cookies: RequestCookies | ReadonlyRequestCookies,
  signedTokens: string,
  options: SetAuthCookiesOptions
) {
  //                                                 v missing part?
  cookies.set(options.cookieName, signedTokens, options.cookieSerializeOptions);
}

I'm not sure if it's the only place, though. :thinking: If there's anything I can help you with, let me know!

awinogrodzki commented 3 weeks ago

Hey @Onxi95!

Thanks for a heads up! I am glad you find the library helpful 🙌

Thanks so much for the reproduction and great problem description. It helped me to immediately focus on the fix.

You are right, I've missed to pass serialization options to cookie setter.

I've prepared a fix and will push to canary branch shortly

awinogrodzki commented 3 weeks ago

I'm not sure if it's the only place, though.

I also fixed two other issues on the occasion. Thanks for that 🎉

The fix has been released in v.1.7.0-canary.9. Could you try it and let me know how it works?

Onxi95 commented 3 weeks ago

Hello @awinogrodzki!

Works like a charm :muscle: Thanks for a really quick response and fix! I think we can close the issue :smile: have a nice day!