[英]Node Express session not working on live server/production
Session is working not live server/ production but its working on local Session 不在实时服务器/生产环境中工作,而是在本地工作
below is my app.js config下面是我的 app.js 配置
app.enable('trust proxy',true);
app.use(cookieParser());
app.use(sessions({
secret: "thisismysecrctekeyfhrgfgrfrty84fwir767",
saveUninitialized:true,
cookie: { maxAge: twoDay,secure:false },
resave: false
}));
I have tried both secure:false
and secure:true
我已经尝试过
secure:false
和secure:true
below is my Nginx config下面是我的 Nginx 配置
server {
listen 8088;
location / {
proxy_pass http://127.0.0.1:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Try by Adding proxy: true in session config as bellow尝试在 session 配置中添加代理:true,如下所示
app.enable('trust proxy',true);
app.use(cookieParser());
app.use(sessions({
proxy: true,
secret: "thisismysecrctekeyfhrgfgrfrty84fwir767",
saveUninitialized:true,
cookie: { maxAge: twoDay,secure:false },
resave: false
}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.