Uncaught TypeError: with Redux Thunk and node.js express wwwhisper middleware on MERN stack application












1















I am building a MERN stack application and trying to use the connect-wwwhisper package to protect access to an application (testing beta version) that I am hosting. I am using passport authentication on the Node js backend for user authentication but I want to layer wwwhisper package on entire app so that only people with approved email may access the entire app without disturbing the passport authentication that I set up. I have set up wwwhisper per the documentation: https://devcenter.heroku.com/articles/wwwhisper but there is a conflict with the redux thunk middleware that is causing a type error within the redux js file below:



    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));


The error message is: Uncaught TypeError: Cannot read property 'apply' of undefined



In my server js file I am using the following to direct requests to the index.html file of the react side of the application. All other requests to the backend api are using the



    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"));
});
}


The wwwhisper middleware does protect the application and sends out the tokenized link to access the application but when I try to access the application I get the above error message along with a message saying the token is unauthorized. The author of the wwwhisper middleware is not familiar with how the wwwhisper middleware may be interacting with the Redux thunk middleware. How can I get this to work? I've been programming for about a year so any help is appreciated.










share|improve this question



























    1















    I am building a MERN stack application and trying to use the connect-wwwhisper package to protect access to an application (testing beta version) that I am hosting. I am using passport authentication on the Node js backend for user authentication but I want to layer wwwhisper package on entire app so that only people with approved email may access the entire app without disturbing the passport authentication that I set up. I have set up wwwhisper per the documentation: https://devcenter.heroku.com/articles/wwwhisper but there is a conflict with the redux thunk middleware that is causing a type error within the redux js file below:



        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));


    The error message is: Uncaught TypeError: Cannot read property 'apply' of undefined



    In my server js file I am using the following to direct requests to the index.html file of the react side of the application. All other requests to the backend api are using the



        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"));
    });
    }


    The wwwhisper middleware does protect the application and sends out the tokenized link to access the application but when I try to access the application I get the above error message along with a message saying the token is unauthorized. The author of the wwwhisper middleware is not familiar with how the wwwhisper middleware may be interacting with the Redux thunk middleware. How can I get this to work? I've been programming for about a year so any help is appreciated.










    share|improve this question

























      1












      1








      1








      I am building a MERN stack application and trying to use the connect-wwwhisper package to protect access to an application (testing beta version) that I am hosting. I am using passport authentication on the Node js backend for user authentication but I want to layer wwwhisper package on entire app so that only people with approved email may access the entire app without disturbing the passport authentication that I set up. I have set up wwwhisper per the documentation: https://devcenter.heroku.com/articles/wwwhisper but there is a conflict with the redux thunk middleware that is causing a type error within the redux js file below:



          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));


      The error message is: Uncaught TypeError: Cannot read property 'apply' of undefined



      In my server js file I am using the following to direct requests to the index.html file of the react side of the application. All other requests to the backend api are using the



          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"));
      });
      }


      The wwwhisper middleware does protect the application and sends out the tokenized link to access the application but when I try to access the application I get the above error message along with a message saying the token is unauthorized. The author of the wwwhisper middleware is not familiar with how the wwwhisper middleware may be interacting with the Redux thunk middleware. How can I get this to work? I've been programming for about a year so any help is appreciated.










      share|improve this question














      I am building a MERN stack application and trying to use the connect-wwwhisper package to protect access to an application (testing beta version) that I am hosting. I am using passport authentication on the Node js backend for user authentication but I want to layer wwwhisper package on entire app so that only people with approved email may access the entire app without disturbing the passport authentication that I set up. I have set up wwwhisper per the documentation: https://devcenter.heroku.com/articles/wwwhisper but there is a conflict with the redux thunk middleware that is causing a type error within the redux js file below:



          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));


      The error message is: Uncaught TypeError: Cannot read property 'apply' of undefined



      In my server js file I am using the following to direct requests to the index.html file of the react side of the application. All other requests to the backend api are using the



          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"));
      });
      }


      The wwwhisper middleware does protect the application and sends out the tokenized link to access the application but when I try to access the application I get the above error message along with a message saying the token is unauthorized. The author of the wwwhisper middleware is not familiar with how the wwwhisper middleware may be interacting with the Redux thunk middleware. How can I get this to work? I've been programming for about a year so any help is appreciated.







      redux redux-thunk wwwhisper






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 18:23









      DataLearnerDataLearner

      64




      64
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287307%2funcaught-typeerror-with-redux-thunk-and-node-js-express-wwwhisper-middleware-on%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287307%2funcaught-typeerror-with-redux-thunk-and-node-js-express-wwwhisper-middleware-on%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          さくらももこ

          13 indicted, 8 arrested in Calif. drug cartel investigation