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
* feat(https): added docs on how to setup https for localhost dev server
* refactor(https): added differentiation on the terminals output regarding the correct, protocol related URL
* chore: simplification
* chore: using markdown instead of HTML
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
* Update packages/docs/src/docs/running-patternlab.md
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
Co-authored-by: Josef Bredreck <slime.games@outlook.de>
| middleware |[function(req, res, next) { next(); }]| Takes an array of Connect-compatible middleware that are injected into the server middleware stack |
239
+
| middleware |[function(req, res, next) { next(); }]| Takes an array of Connect-compatible middleware that are injected into the server middleware stack |
240
+
| https | 'ssl/ssl.js' | adding the path to a configuration module for HTTPS dev servers, see detailed explanation on the[`running patternlab` page](/docs/running-pattern-lab/#heading-running-localhost-via-https)|
Copy file name to clipboardExpand all lines: packages/docs/src/docs/running-patternlab.md
+63Lines changed: 63 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,3 +25,66 @@ Relevant information regarding and step and possible errors are being logged to
25
25
### Problems and errors after restructuring files and folders
26
26
27
27
If you're doing bigger changes especially to the file and folder structure and recognize some errors on the console like e.g. `TypeError: Cannot read property 'render' of undefined` or `Error building BuildFooterHTML`, it's recommended to stop Pattern Lab, delete the cache file `dependencyGraph.json` within the projects root and start Pattern Lab again, as these changes might conflict with the existing cache structures.
28
+
29
+
### Running localhost via HTTPS
30
+
31
+
There might be use cases in which you'd like to let your [localhost dev server run via HTTPS instead of HTTP](https://github.com/pattern-lab/live-server#https), like e.g. when consuming from other secure contexts to prevent browser errors or problems.
32
+
33
+
Achieving this is a three-step process:
34
+
- generate a self-signed SSL certificate
35
+
- add it to the trusted certificates
36
+
- configure the certificates for `live-server`
37
+
38
+
#### Generate a self-signed SSL certificate
39
+
40
+
First, create a folder like, e.g., `ssl` at the root of your project.
This has been adapted from <https://stackoverflow.com/a/56074120> according to the [`Let's encrypt` instructions](https://letsencrypt.org/docs/certificates-for-localhost/); additionally, DigitalOcean provides some further explanations in [a tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-16-04).
54
+
55
+
#### Add the certificate to the trusted certificates
56
+
57
+
A [stack overflow entry](https://stackoverflow.com/a/56074120) as well mentions using the following command to add the certificate to the trusted certificates, as [suggested on a blog](https://derflounder.wordpress.com/2011/03/13/adding-new-trusted-root-certificates-to-system-keychain/):
You could as well skip this step and accept the certificate after opening the secured pattern lab in your browser for the first time, as described in step 5 of the [DigitalOcean tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-16-04#step-5-test-encryption).
64
+
65
+
#### Configure the certificates for `live-server`
66
+
67
+
According to the [`live-server` documentation](https://github.com/pattern-lab/live-server#https), you'll then add those certificates to the local dev server:
68
+
69
+
> To enable HTTPS support, you'll need to create a configuration module.
70
+
71
+
In our case, you could, e.g., create a file called `ssl.js` in the `ssl` folder with the following contents:
72
+
73
+
```js
74
+
var fs =require("fs");
75
+
76
+
module.exports= {
77
+
cert:fs.readFileSync(__dirname+"/localhost.crt"),
78
+
key:fs.readFileSync(__dirname+"/localhost.key")
79
+
};
80
+
```
81
+
82
+
Finally, you'll have to add this as a configuration module to the pattern lab `serverOptions` within the `patternlab-config.json` file:
83
+
```json
84
+
"serverOptions": {
85
+
...
86
+
"https": "ssl/ssl.js"
87
+
},
88
+
```
89
+
90
+
Et voilà, after starting the process of serving pattern lab the next time, it'll open as a secured page.
0 commit comments