小编bat*_*get的帖子

hapi-auth-cookie无法加载会话策略

hapi及其auth-cookie插件的例子并不多,但这是我迄今为止尝试确保路由的例子.请注意,我见过的大部分示例都使用的是较旧版本的hapi,这似乎并不适用于这种情况,我希望我只是遗漏了一些简单的东西:

var Hapi = require('hapi');
var Mongoose = require('mongoose');

Mongoose.connect('mongodb://localhost/rfmproducetogo');

var server = new Hapi.Server(8080, "localhost");

server.pack.register([{
    plugin: require("lout")
}, {
    plugin: require('hapi-auth-cookie')
}, {
    plugin: require("./plugins/togo")
}, {
    plugin: require("./plugins/auth")
}], function(err) {
    if (err) throw err;
    server.auth.strategy('session', 'cookie', {
        password: 'shhasecret',
        cookie: 'wtfisthisfor',
        isSecure: false,
        redirectTo: false
    });
    server.start(function() {
        console.log("hapi server started @ " + server.info.uri);
    });
});
Run Code Online (Sandbox Code Playgroud)

在我的togo插件中,我有这个路由设置来使用会话

exports.create = function(plugin) {
    plugin.route({
        method: 'POST',
        path: '/togo/add',
        handler: function(request, reply) {
            produce = new Produce();
            produce.label …
Run Code Online (Sandbox Code Playgroud)

node.js hapijs

5
推荐指数
1
解决办法
1311
查看次数

标签 统计

hapijs ×1

node.js ×1