Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
req.protocol always http in 3.0.0beta7
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jhspaybar  
View profile  
 More options Sep 6 2012, 12:00 pm
From: jhspaybar <wthur...@ucr.edu>
Date: Thu, 6 Sep 2012 09:00:25 -0700 (PDT)
Local: Thurs, Sep 6 2012 12:00 pm
Subject: req.protocol always http in 3.0.0beta7

I'm trying to redirect to an https connection if requests come in on http.
 I've done this before on heroku using the X-Forwarded-Proto field that
express will fall back on as well.  However, when I'm on my local machine,
my https requests think they're still http.  Chrome is giving me the red X
through my lock on the address bar, but according to the description it
sounds like my connection is still with TLS and secure, just that it can't
verify my certificate with a third party(as expected, I generated it
myself).  Does anyone know what's going on?

(I know this won't actually redirect to port 3001 as I need it to as well,
however when I hit https://localhost:3001 it redirect loops and then Chrome
aborts, I'd like to fix that behavior if possible as it
thinks https://localhost:3001 is http for some reason).

Here's my code:

app.get('*', function(req, res, next) {
  if(req.protocol == 'http') {
    console.log('redirecting');
    res.redirect('https://' + req.headers.host + req.url);
  } else {
    console.log('next');
    next();
  }

});

app.get('/', routes.index);

http.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));

});

spdy.createServer(https.Server, options, app).listen(app.get('port') + 1,
function(){
  console.log("Express server listening on port " + (app.get('port') + 1));


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »