Node.js session-file-store will abort all following requests

与世无争的帅哥 提交于 2021-02-10 15:04:43

问题


I'm creating simple web app in node.js which should be able to save session data into file store.

For this purpose I'm using express-session with session-file-store module:

var session = require('express-session');
var FileStore = require('session-file-store')(session);

app.use(session({
    store: new FileStore({
        path:'./sessions/',
    }),
    secret: 'keyboard cat'
}));

But when I visit some page of my website, I will successfully receive generated HTML file, but all other request for assets will be aborted:

Aborted requests except first one

When I comment store attribute, it works fine.. but it won't save session data into files.

Does anybody know, what's wrong here? Or do you know any other module for storing session data into files?

Thanks for any advice..


回答1:


It seems like you have problems with permissions on your file system if it works with default in memory storage.


Try to create session store this way:

new FileStore({
   path:  require('path').join(require('os').tmpdir(), 'sessions')
})

It has to resolve this issue.



来源:https://stackoverflow.com/questions/28919667/node-js-session-file-store-will-abort-all-following-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!