[英]Is it possible that I can override NestJS SessionModule cookie domain during request?
I have a NestJS
where I use SessionModule
for user cookies, and it's all working great, but I need to override the domain name for some requests.我有一个
NestJS
,我在其中为用户 cookies 使用SessionModule
,一切都很好,但我需要为某些请求覆盖域名。 Not sure how can I do this in NestJS
, the actual setting of the domain seems to be in the imports
array of a module, there is no room where I can inject req: Request
不知道如何在
NestJS
中执行此操作,域的实际设置似乎在模块的imports
数组中,没有空间可以注入req: Request
@Module({
imports: [
SessionModule.forRoot({
session: {
secret: 'someSecret',
name: `ssid`,
cookie: {
maxAge: 1234125645654,
domain: '' // I need to set this sometimes during some requests.
},
},
}),
],
export class AppModule implements NestModule, OnModuleInit { }
It turns out to be as easy as req.session.cookie.domain = 'example.com'
结果就像
req.session.cookie.domain = 'example.com'
一样简单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.