Force https on stackedit.io
This commit is contained in:
		
							parent
							
								
									f1f21df46d
								
							
						
					
					
						commit
						866732bdae
					
				@ -1,7 +1,8 @@
 | 
				
			|||||||
var express = require('express');
 | 
					var express = require('express');
 | 
				
			||||||
var app = express();
 | 
					var app = express();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Force HTTPS on stackedit.io
 | 
				
			||||||
app.all('*', function(req, res, next) {
 | 
					app.all('*', function(req, res, next) {
 | 
				
			||||||
    console.log(req.headers);
 | 
					 | 
				
			||||||
    if (req.headers.host == 'stackedit.io' && req.headers['x-forwarded-proto'] != 'https') {
 | 
					    if (req.headers.host == 'stackedit.io' && req.headers['x-forwarded-proto'] != 'https') {
 | 
				
			||||||
        res.redirect('https://stackedit.io' + req.url);
 | 
					        res.redirect('https://stackedit.io' + req.url);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -9,6 +10,12 @@ app.all('*', function(req, res, next) {
 | 
				
			|||||||
        next();
 | 
					        next();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Use gzip compression
 | 
				
			||||||
app.use(express.compress());
 | 
					app.use(express.compress());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Serve static resources
 | 
				
			||||||
app.use(express.static(__dirname + '/public'));
 | 
					app.use(express.static(__dirname + '/public'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Listen on port 3000
 | 
				
			||||||
app.listen(process.env.PORT || 3000);
 | 
					app.listen(process.env.PORT || 3000);
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user