0

Using Node/Express in a Heroku hosted app. I have an http to https forwarding function, which had worked but no longer.

I had forwarding working with the following from my app.configure('production'...:

app.configure('production', function() {
return app.use(function(req, res, next) {
    if (req.header('x-forwarded-proto') !== 'https') {
        return res.redirect("https://" + (req.header('host')) + req.url);
    } else {
        return next();
    }
});

It worked, I was satisfied and moved on to implement Redis-to-go instead of MemoryStorage and then to implement csrf middleware. Both of those features are working but now I'm finding that I can access my app through http://... whereas before that would have been caught and auto-forwarded to the https://... and the friendly green padlock.

Any idea what could have gone sour in the interim?

Wylie Kulik
  • 696
  • 5
  • 17

1 Answers1

0

Self-answer:

Somewhere during the csrf implementation process, I made the following change to my app.configure section:

app.use(app.router);

I'd read this usage in the csrf demonstrations. But I don't know if it's necessary. Csrf middleware functionality seems un-affected when I commented that line out, and the Heroku redirect works as before.

Wylie Kulik
  • 696
  • 5
  • 17