A modular, personalisable HTTP, HTTPS and HTTP2 command-line web server.
A lean, modular web server for rapid full-stack development.
* Supports HTTP, HTTPS and HTTP2.
* Small and 100% personalisable. Load and use only the behaviour required by your project.
* Attach a custom view to personalise how activity is visualised.
* Programmatic and command-line APIs.
Use this tool to:
* Build any type of front-end web application (static, dynamic, Single Page App, Progessive Web App, React etc).
* Prototype a back-end service (REST API, microservice, websocket or Server Sent Events service etc).
* Monitor activity, analyse performance, fine-tune caching strategy etc.
* Prototype a back-end service (REST API, microservice, websocket, Server Sent Events service etc).
* Monitor activity, analyse performance, experiment with caching strategy etc.
Local-web-server is a distribution of [lws](https://github.com/lwsjs/lws) bundled with a "starter pack" of useful middleware.
@ -67,35 +72,35 @@ This clip demonstrates the above plus use of `--static.extensions` to specify a
<imgsrc="https://imgur.com/download/3flcbJn"width="618px"title="Proxy json requests to remote resource">
### HTTPS
### HTTPS and HTTP2
Launch a secure server by setting the `--https` flag. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further configuration options and a guide on how to get the "green padlock" in your browser.
For HTTPS or HTTP2, pass the `--https` or `--http2` flags respectively. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further configuration options and a guide on how to get the "green padlock" in your browser.
```sh
$ ws --https
```
### HTTP2
Launch a secure HTTP2 server. Follow the same instructions as `--https` to use certs, get the "green padlock" etc.
```sh
$ ws --http2
$ lws --http2
Listening at https://mba4.local:8000, https://127.0.0.1:8000, https://192.168.0.200:8000
```
## Features
* Full control over request handling. The middleware stack is personalisable - use one or more custom or pre-built middleware plugins.
* Single Page Application (SPA) support
* URL Rewriting
* Proxy requests to remote resources
* HTTP Conditional Request support
* Range request support
* Gzip response compression
* HTTP Basic Authentication
* Configurable access log
* Route blacklisting and more
## Built-in middleware stack
If you do *not* supply a custom middleware stack via the `--stack` option the following default stack will be used. It's designed to cover most typical web development scenarios.
| Name | Description |
| ------------------ | ---- |
| ↓ [Basic Auth](https://github.com/lwsjs/basic-auth) | Password-protect a server using Basic Authentication |
| ↓ [Body Parser](https://github.com/lwsjs/body-parser) | Parses the request body, making `ctx.request.body` available to downstream middleware.|
| ↓ [Request Monitor](https://github.com/lwsjs/request-monitor) | Feeds traffic information to the `--verbose` output.|
| ↓ [Log](https://github.com/lwsjs/log) | Outputs an access log or stats view to the console.|
| ↓ [Cors](https://github.com/lwsjs/cors) | Support for setting Cross-Origin Resource Sharing (CORS) headers |