Merge pull request #13 from daquinoaldo/develop-4.1.0 · TimDaub/https-localhost@186b5ba · GitHub
Skip to content

Commit 186b5ba

Browse files
authored
Merge pull request daquinoaldo#13 from daquinoaldo/develop-4.1.0
Develop 4.1.0
2 parents 49792e1 + 3dc0988 commit 186b5ba

10 files changed

Lines changed: 2026 additions & 1497 deletions

File tree

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 3 additions & 4 deletions

‎.gitignore‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
# MacOS
22
.DS_STORE
33

4-
# IDEs
5-
.idea
6-
*.iml
7-
8-
# Node & npm
4+
# Node, npm & CI
95
node_modules
106
coverage
117
.nyc_output
128

13-
# Certificates
14-
cert/localhost.*
15-
cert/mkcert-*
9+
# Build
10+
build

‎.travis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ language: node_js
66
node_js:
77
- node
88
- 10
9-
- 7.6
9+
- 8
1010
after_success: npm run coveralls

‎README.md‎

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,32 @@ It works with MacOS, Linux and Windows, on Chrome and Firefox, and requires you
1212
[![Known Vulnerabilities](https://snyk.io/test/npm/https-localhost/badge.svg)](https://snyk.io/test/npm/https-localhost)
1313
[![GitHub issues](https://img.shields.io/github/issues/daquinoaldo/https-localhost.svg)](https://github.com/daquinoaldo/https-localhost/issues)
1414

15+
1516
## Install and use standalone
1617
```
17-
npm i -g https-localhost
18+
npm i -g --only=prod https-localhost
1819
```
1920
```
2021
serve ~/myproj
2122
```
2223
- `sudo` may be necessary.
2324
- If a static path is not provided the current directory content will be served.
24-
- You can change the port setting the PORT environmental variable: `PORT=4433 serve ~/myproj`.
25+
- You can change the **port** setting the `PORT` environmental variable: `PORT=4433 serve ~/myproj`. Specifying port number will also prevent http to https redirect.
26+
27+
### Binaries
28+
If you don't have Node.js installed just use a packaged version! Download it from the [release page](https://github.com/daquinoaldo/https-localhost/releases).
29+
```
30+
// Linux
31+
./https-localhost-linux ~/myproj
32+
33+
// MacOS
34+
./https-localhost-macos ~/myproj
35+
36+
// Windows
37+
./https-localhost-win.exe C:\User\me\myproj
38+
```
39+
**Tip 1:** on Windows just drag the folder on the executable to serve itV.
40+
**Tip 2:** on all platform put the executable on the folder you want to serve and double-click it.
2541

2642

2743
## Use as module
@@ -36,9 +52,13 @@ const app = httpLocalhost()
3652
// app is an express app, do what you usually do with express
3753
app.listen(port)
3854
```
39-
- If the port number is not provided, it will listen on 443.
40-
- To redirect the http traffic to https use `app.redirect()`.
41-
- You can serve static files with `app.serve(path)`.
55+
- If the **port** number is not provided, it will listen on 443.
56+
- To **redirect** the http traffic to https use `app.redirect()`.
57+
- You can serve **static files** with `app.serve(path)`.
58+
59+
**Tip:** consider installing it as a dev dependency: this is not a production tool!
60+
`npm i --save-dev https-localhost`
61+
4262

4363
## Production
4464
This tool has a production version that activates **HTTP/2**, **compression** and **minify**.
@@ -49,6 +69,7 @@ I decide to not activate it by default since it is usually an unwanted behaviour
4969

5070
**IMPORTANT**: the fact that there is a production enviornment doesn't mean that this tool is suitable for production. It's intended to be used only for local testing.
5171

72+
5273
## Why and how it works
5374
Serving static content on localhost in a trusted SSL connection is not so simple.
5475
It requires to manually generate and trust certificates, with complicate commands and many manual steps.
@@ -76,9 +97,19 @@ Checkout the updated list [here](https://github.com/FiloSottile/mkcert/blob/mast
7697

7798
## Troubleshooting
7899
### Node.js version
79-
https-localhost requires Node.js 7.6 or higher.
100+
https-localhost requires Node.js 8 or higher.
80101
<sub>If you need compatibility with previously Node.js versions let me know, I'll try to rearrange the code.</sub>
81102

103+
### root required
104+
- **At first run** this tool generate a trusted certificate. The sudo password may be required. If you cannot provide the sudo password generate a `localhost.key` and `localhost.crt` and specify its path with `CERT_PATH=/diractory/containing/certificates/ serve ~/myproj`.
105+
- **At each run** the password may be required to run the server on port 443 and 80. To avoid the script ask for password specify a different port number: `PORT=4433 serve ~/myproj`.
106+
107+
### EACCES
108+
Run with sudo to use the default ports 443 and 80. You can also change port with: `PORT=4433 serve ~/myproj`.
109+
110+
### EADDRINUSE
111+
Another service on your machine is using port 443 or port 80. Stop it or change port with `PORT=4433 serve ~/myproj`.
112+
82113
### RangeError
83114
```
84115
RangeError: Invalid typed array length: -4095
@@ -89,6 +120,12 @@ It should be present only with `NODE_ENV=production`, hence the easiest fix is t
89120

90121
I've tried to reproduce this error without any success (checkout the [Travis build logs](https://travis-ci.org/daquinoaldo/https-localhost)). If you can help please open an issue and describe as better as you can how to reproduce it, I'll be happy to help you.
91122

123+
124+
## Contributing
125+
Each contribute is welcome!
126+
Please, checkout the [contributing guidelines](.github/CONTRIBUTING.md).
127+
128+
92129
## License
93130
Is released under [AGPL-3.0 - GNU Affero General Public License v3.0](LICENSE).
94131

‎cert/generate.js‎

Lines changed: 0 additions & 85 deletions
This file was deleted.

‎certs.js‎

Lines changed: 140 additions & 0 deletions

0 commit comments

Comments
 (0)