Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

express http to https

var express = require('express');var app = express(); var redirectToHTTPS = require('express-http-to-https').redirectToHTTPS // Don't redirect if the hostname is `localhost:port` or the route is `/insecure`app.use(redirectToHTTPS([/localhost:(d{4})/], [//insecure/], 301)); app.get('/', function (req, res) {  res.send('Hello World!');}); app.get('/insecure', function (req, res) {  res.send('Dangerous!');}); app.listen(3000, function () {  console.log('Example app listening on port 3000!');}); app.listen(8080, function () {  console.log('Example app listening on port 8080 insecurely!');});
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #express #http #https
ADD COMMENT
Topic
Name
3+3 =