@ladjs/proxy
Advanced tools
Comparing version 1.0.0 to 1.0.1
14
index.js
@@ -18,2 +18,5 @@ const http = require('http'); | ||
}, | ||
// useful option if you don't need https redirect | ||
// (e.g. it's just a certbot server) | ||
redirect: true, | ||
...config | ||
@@ -38,8 +41,9 @@ }; | ||
router.use((req, res) => { | ||
res.writeHead(301, { | ||
Location: parse(`https://${req.headers.host}${req.url}`).href | ||
if (this.config.redirect) | ||
router.use((req, res) => { | ||
res.writeHead(301, { | ||
Location: parse(`https://${req.headers.host}${req.url}`).href | ||
}); | ||
res.end(); | ||
}); | ||
res.end(); | ||
}); | ||
@@ -46,0 +50,0 @@ this.server = http.createServer((req, res) => { |
{ | ||
"name": "@ladjs/proxy", | ||
"description": "Proxy for Lad", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -6,0 +6,0 @@ "ava": { |
@@ -6,2 +6,9 @@ const test = require('ava'); | ||
test('starts and stops server', async t => { | ||
const proxy = new ProxyServer(); | ||
await proxy.listen(); | ||
await proxy.close(); | ||
t.pass(); | ||
}); | ||
test('redirects http to https', async t => { | ||
@@ -16,2 +23,9 @@ const proxy = new ProxyServer(); | ||
test('does not redirect http to https', async t => { | ||
const proxy = new ProxyServer({ redirect: false }); | ||
await proxy.listen(); | ||
const res = await request(proxy.server).get('/foobar'); | ||
t.is(res.status, 404); | ||
}); | ||
test('serves acme challenge', async t => { | ||
@@ -18,0 +32,0 @@ const config = { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8238
94
1