iamolegga / nestjs-cookie-session

Idiomatic Cookie Session Module for NestJS. Built on top of `cookie-session` 😻

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] Applied cookies for particular controllers only

kosiakMD opened this issue · comments

[x] I've read the docs

[x] I've read the docs of cookie-session

[x] I couldn't find the same question

Question
As far as I see, this module can't be applied for particular controllers only, isn't it?

My use-case: we have some public controllers for a public (end-users) subdomain and want to use cookies applied to a current subdomain, and we don't need to parse cookies for other subdomains and retrieve data. Also, we don't need too much protection for the user's cart as it's not something sensitive, e.g., httpOnly: true is redundant.

So, I would like to apply it only for specific modules and controllers. Is it possible?

Please mention other relevant information such as Node.js version and Operating System.

  1. Did you try to provide forRoutes/exclude to https://github.com/iamolegga/nestjs-cookie-session?tab=readme-ov-file#nestcookiesessionoptions ? Please look at https://docs.nestjs.com/middleware#applying-middleware on how to configure it properly

  2. Cookie options could be set via session, https://github.com/expressjs/cookie-session?tab=readme-ov-file#cookie-options

Does it solve your issue?

@iamolegga, thank you for the answer, seems it's my case solution
I don't want to reinvent the wheel and have a leak of time, so I found your module pretty nice and very similar to the flow I used in modules already created in the app.
Thank you very much!