我在同一个IP和不同端口有2个Web应用程序:
我正在使用Nginx并为这两个应用程序设置2个代理。用户必须登录app1,系统才会为登录用户设置会话。之后该系统将用户重定向到app2,我需要访问appp2中登录的用户会话。 我将我的会话存储在同一个收集器中的mongodb中,两个应用程序都可以访问它。
我的问题是我无法访问app2中的登录用户会话。
这是我的会话设置:
APP1:
const MongoStore = require('connect-mongo')(session);
mongoose.Promise = require('bluebird');
const connection = mongoose.createConnection(config.dbhost, function(err){
if(err){
console.log(err);
} else {
console.log('connected to the database successfuly.');
}
});
/* Session config */
var expiryDate = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) // 7 days
app.use(session({
secret: config.secureHasherKey ,
resave: true,
saveUninitialized: false,
cookie: {
secure: false,
httpOnly: true,
domain: 'login.site.com',
path: '/',
expires: expiryDate
},
store: new MongoStore({ mongooseConnection: connection })
}));
APP2:
app.all("*", function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Cache-Control, Pragma,
Origin, Authorization, Content-Type, X-Requested-With");
res.header("Access-Control-Allow-Methods", "GET, PUT, POST");
return next();
});
这是我的CORS设置:
<form id="CreateAttachmentForm" method="post" enctype="multipart/form-data" action="../../uploadFile" >
<input type="file" id="fileupload1" name="fileupload1" accept="image/*,application/pdf" "/>
<contact:contactbutton
id="printButton"
style="position:relative; width:90px; top:27px; height:30px; left:160px;"
textTop="7px"
defaultButton="false"
tabindex=""
accesskey="C"
onClick="return createAttachmentRequest(this.form, this.fileupload1 );"
onfocus="if(event.altKey){click();}">
<u>C</u>reate
</contact:contactbutton>
function createAttachmentRequest(form,fileupload1){
att=form.action;
$.post(att, {fileupload1: fileupload1.value}).done(function(data){
});
return true;
如何找到问题?