Closed lifubang closed 3 years ago
The ops.secure
is an option you pass into the constructor of this module: https://github.com/pillarjs/cookies#cookies--new-cookies-request-response--options--
You should pass in true when the connection is https.
No, the web server doesn't know whether the client uses https or not, because the nginx use http to connect the backend web server.
Right, that is why the constructor here you set if it is or not.
The client use https to connect nginx, the nginx use http to connect the backend web server. This is a common architecture of a web site, we should let secure cookie work.
This module does work with that configuration just fine. Just set secure: true
in the constructor this module provides.
I use koa2, how to set this option?
I'm not familiar with what koa2 is. I just maintain this module, which is where you opened this issue at. This module provides an API to do exactly what you want. If this module is being used by another module and not by you directly, you should open your issue in that module to get the API information that above layer provides.
When the web server is behind a
nginx
, the value ofthis.secure
is alwaysfalse
thought we usehttps
protocol to connect the nginx. So we will get the error like this:Because of this check, we can't use
cookie.secure
anymore if the web servers are behind the nginx. So I suggest to remove the secure connection check when we setcookie.secure=true
.Signed-off-by: lfbzhm lifubang@acmcoder.com