Uncaught TypeError:与Redux Thunk和node.js在MERN堆栈应用程序上表达wwwhisper中间件

时间:2018-11-13 18:23:03

标签: redux redux-thunk wwwhisper

我正在构建MERN堆栈应用程序,并尝试使用connect-wwwhisper包来保护对我所托管的应用程序(测试Beta版)的访问。我正在Node js后端上使用护照认证进行用户认证,但我想在整个应用程序上放置wwwhisper包,以便只有获得批准的电子邮件的人才能访问整个应用程序,而不会干扰我设置的护照认证。我已经按照文档wwwhisper进行了设置:https://devcenter.heroku.com/articles/wwwhisper,但是与redux thunk中间件存在冲突,导致以下redux js文件内出现类型错误:

    function compose() {
    for (var _len = arguments.length, funcs = new Array(_len), _key = 
    0; 
    _key < _len; _key++) {
    funcs[_key] = arguments[_key];
    }

    if (funcs.length === 0) {
    return function (arg) {
      return arg;
    };
    }

    if (funcs.length === 1) {
    return funcs[0];
    }

    return funcs.reduce(function (a, b) {
    return function () {
      return a(b.apply(void 0, arguments));

错误消息是:Uncaught TypeError: Cannot read property 'apply' of undefined

在我的服务器js文件中,我正在使用以下命令将请求定向到应用程序反应端的index.html文件。对后端api的所有其他请求都使用

    app.use("routename");

    if (process.env.NODE_ENV === "production") {
      app.use(express.static("client/build"));
      app.get("*", (req, res) => {
      res.sendFile(path.resolve(__dirname, "client", "build", 
      "index.html"));
     });
     }

wwwhisper中间件确实保护应用程序并发出令牌化链接来访问该应用程序,但是当我尝试访问该应用程序时,我收到上述错误消息以及一条消息,指出令牌未经授权。 wwwhisper中间件的作者并不熟悉wwwhisper中间件如何与Redux thunk中间件进行交互。我该如何工作?我已经进行了大约一年的编程,所以对您的帮助表示赞赏。

0 个答案:

没有答案