Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ If your reverse proxy sends the original host using the `X-Forwarded-Host` heade
app.use(enforce.HTTPS({ trustXForwardedHostHeader: true }))
```

### Exclude Certain Paths from Being Redirected

You can exlude a path that starts with given string by including a list called `skips`:

```javascript
app.use(enforce.HTTPS({ skips: ['/healthcheck'] }))
```

## Tests
Download the whole repository and call:
```shell
Expand Down
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ function applyOptions(options) {
return settings;
}

function skip(request, options){
//checks the skip list
let skipList = options.skips;
if(skipList && Array.isArray(skipList)){
for(let i = 0; i < skipList.length; i++){
if(request.path.startsWith('/' + skipList[i])){
return true;
}
}
}
return false;
}

/**
* enforceHTTPS
*
Expand Down Expand Up @@ -56,6 +69,11 @@ var enforceHTTPS = function(options) {
isHttps = true;
}

//checks skips array
if(skip(req, options)){
isHttps = true;
}

if(isHttps) {
next();
} else {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "express-sslify",
"version": "1.2.0",
"name": "express-sslify2",
"version": "0.0.1",
"description": "Enforces SSL for node.js express projects",
"main": "index.js",
"scripts": {
"test": "grunt test"
},
"repository": {
"type": "git",
"url": "https://github.com/florianheinemann/express-sslify.git"
"url": "https://github.com/jmeeke02/express-sslify.git"
},
"keywords": [
"express",
Expand All @@ -19,12 +19,12 @@
"http",
"redirect"
],
"author": "Florian Heinemann <florian.heinemann@gmail.com> (http://twitter.com/florian__h)",
"author": "Jordan Meeker <jordanwmeeker@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/florianheinemann/express-sslify/issues"
"url": "https://github.com/jmeeke02/express-sslify/issues"
},
"homepage": "https://github.com/florianheinemann/express-sslify",
"homepage": "https://github.com/jmeeke02/express-sslify",
"devDependencies": {
"chai": "^3.0.0",
"express": "^4.13.1",
Expand Down