atinux / nuxt-auth-utils

Add Authentication to Nuxt applications with secured & sealed cookies sessions.
MIT License
981 stars 91 forks source link

How to set maxAge to cookie? #139

Closed Serpentarius13 closed 2 months ago

Serpentarius13 commented 3 months ago

There is no such option as of now in config settings, only sameSite under cookie

Barbapapazes commented 3 months ago

Hey,

Do you try this? https://github.com/atinux/nuxt-auth-utils#configuration

Serpentarius13 commented 3 months ago

Hey,

Do you try this? https://github.com/atinux/nuxt-auth-utils#configuration

Yes. But the type only allows sameSite property on cookie

atinux commented 2 months ago

You need to use the session config:

export default defineNuxtConfig({
  modules: ['nuxt-auth-utils'],
  runtimeConfig: {
    session: {
      maxAge: 60 * 60 * 24 * 7 // 1 week
    }
  }
})

It will forward it to the cookie.

Serpentarius13 commented 2 months ago

image

But why does the type not work? This is RuntimeConfig dts @atinux

Barbapapazes commented 2 months ago

Because it's generated on the fly

https://github.com/user-attachments/assets/df43f3b8-96e5-4ed6-98cd-7f11ba917069

And the defaults are the following

Screenshot 2024-08-29 at 14 43 31

so the generated runtimeConfig only have keys name, password and sameSite.

Serpentarius13 commented 2 months ago

Because it's generated on the fly

Screen.Recording.2024-08-29.at.14.42.06.mov And the defaults are the following

Screenshot 2024-08-29 at 14 43 31

so the generated runtimeConfig only have keys name, password and sameSite.

Wouldn't it be sane to generate the type for maxAge? What's the problem here?