Node.js会话文件存储将中止所有以下请求 [英] Node.js session-file-store will abort all following requests

查看:33
本文介绍了Node.js会话文件存储将中止所有以下请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在node.js中创建简单的Web应用程序,该应用程序应该能够将会话数据保存到文件存储中.

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

为此,我将 express-session session-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'
}));

但是,当我访问网站的某些页面时,我将成功接收生成的HTML文件,但是所有其他资产请求都将中止:

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:

当我评论存储属性时,它可以正常工作..但不会将会话数据保存到文件中.

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?

谢谢您的建议.

推荐答案

如果在内存存储中使用默认文件系统,则似乎对文件系统的权限存在疑问.

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')
})

它必须解决此问题.

这篇关于Node.js会话文件存储将中止所有以下请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆