Skip to content

Commit 0feba09

Browse files
committed
server-ssl.js
fixes a bug that was preventing the redirect from working correctly /root │ ├── /error │ ├── 404.html │ └── 500.html │ ├── /ssl │ ├── /openssl │ ├── /production │ │ │ │ │ ├── ... │ │ ├── private-key.pem │ │ └── certificate.pem │ │ │ ├── /staging │ │ │ │ │ ├── ... │ │ ├── private-key.pem │ │ └── certificate.pem │ │ │ └── state.js │ ├── /wwwroot │ └── index.html <---- Your website goes here │ └── server-ssl.js
1 parent b19c9c9 commit 0feba09

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "server-ssl",
33
"author": "FirstTimeEZ",
4-
"version": "40.0.1",
4+
"version": "40.0.2",
55
"description": "Configurable SSL Server that runs on Node.js which can be used for development or production and can create and renew Lets Encrypt Certificates automatically using ACME",
66
"main": "template; do not import; read the Getting Started of the README, maybe you want to use: lets-encrypt-acme-client",
77
"type": "module",

ssl/state.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,11 @@ export const STATE = {
262262
res.end();
263263
},
264264
startHttpChallengeListener: () => {
265-
createServerHTTP((req, res) => STATE.optLetsEncrypt ? !checkChallengesMixin(req, res) && STATE.redirect(res, req) : STATE.redirect(res, req))
266-
.on('error', (e) => e.code === STATE.ADDR_IN_USE && console.error(`${STATE.optPortHttp}${STATE.IN_USE}`))
267-
.listen(STATE.optPortHttp, () => console.log(`${STATE.STARTED_HTTP}${STATE.optPort}`)); // Lets Encrypt! HTTP-01 ACME Challenge Mixin - Always Redirect HTTP to HTTPS unless doing a ACME Challenge
265+
createServerHTTP(async (req, res) => {
266+
if (STATE.optLetsEncrypt && await checkChallengesMixin(req, res)) { return; }
267+
268+
STATE.redirect(res, req);
269+
}).on('error', (e) => e.code === STATE.ADDR_IN_USE && console.error(`${STATE.optPortHttp}${STATE.IN_USE}`)).listen(STATE.optPortHttp, () => console.log(`${STATE.STARTED_HTTP}${STATE.optPort}`)); // Lets Encrypt! HTTP-01 ACME Challenge Mixin - Always Redirect HTTP to HTTPS unless doing a ACME Challenge
268270
},
269271
defaultFileHandling: (res, route, contentTypes) => {
270272
const fileExtension = _extname(route);

0 commit comments

Comments
 (0)