You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- You can change the port setting the PORT environmental variable: `PORT=4433 serve ~/myproj`.
27
25
28
26
29
-
###Use as module
30
-
Install the dependency
27
+
## Use as module
28
+
Install as a dependency:
31
29
```
32
30
npm i -s https-localhost
33
31
```
34
-
35
-
Put in your `index.js` file:
32
+
Then put in your `index.js` file:
36
33
```
37
34
const app = require("https-localhost")
38
35
// app is an express app, do what you usually do with express
@@ -42,6 +39,15 @@ app.listen(port)
42
39
- To redirect the http traffic to https use `app.redirect()`.
43
40
- You can serve static files with `app.serve(path)`.
44
41
42
+
## Production
43
+
This tool has a production version that activates **HTTP/2**, **compression** and **minify**.
44
+
```
45
+
NODE_ENV=production serve ~/myproj
46
+
```
47
+
I decide to not activate it by default since it is usually an unwanted behaviour for localhost testing, but sometimes it could be userful, e.g. to test Progressive Web Application or more ingeneral the website performances.
48
+
49
+
**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.
50
+
45
51
## Why and how it works
46
52
Serving static content on localhost in a trusted SSL connection is not so simple.
47
53
It requires to manually generate and trust certificates, with complicate commands and many manual steps.
@@ -67,6 +73,21 @@ Checkout the updated list [here](https://github.com/FiloSottile/mkcert/blob/mast
67
73
- Java (when `JAVA_HOME` is set)
68
74
69
75
76
+
## Troubleshooting
77
+
### Node.js version
78
+
https-localhost requires Node.js 7.6 or higher.
79
+
<sub>If you need compatibility with previously Node.js versions let me know, I'll try to rearrange the code.</sub>
80
+
81
+
### RangeError
82
+
```
83
+
RangeError: Invalid typed array length: -4095
84
+
```
85
+
It is a known bug of `spdy` that is present sometimes with some old Node.js versions.
86
+
87
+
It should be present only with `NODE_ENV=production`, hence the easiest fix is to avoid using the production env. Anyway, if you need the production env, you can try to update Node.js to the latest release, or to the most stable LTS version.
88
+
89
+
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.
90
+
70
91
## License
71
92
Is released under [AGPL-3.0 - GNU Affero General Public License v3.0](LICENSE).
0 commit comments