[![Join the chat at https://gitter.im/lwsjs/local-web-server](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lwsjs/local-web-server?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
***Requires node v7.6 or higher. Install the [previous release](https://github.com/lwsjs/local-web-server/tree/prev) for older node support.***
***Requires node v7.6 or higher. Install the [previous release](https://github.com/lwsjs/local-web-server/tree/v1.x) for older node support. Documentation still WIP.***
# local-web-server
At its core, local-web-server is an application shell for building a specialised command-line web server to support productive Web Platform engineers. When combined with built-in and custom features it's in intended to by a powerful tool in helping build and debug Web applications. It comes bundled with a middleware stack covering common requirements but any arbitrary stack can be specified from the command line or config.
Being an npm module, it is trivial is bundle and distribute/deploy with your web application.
A convenient local web server to support productive, full-stack Javascript development. Built on [lws](https://github.com/lwsjs/lws).
**Typically used for building:**
**Features**
* Simple static site
* Single Page Application
* Works well with React, Angular or vanilla JS.
- Lightweight
- http/https ([http2](https://github.com/nodejs/http2) will be added once ready)
- Rewrite routes to local or remote resources
- Url rewriting
- Proxy certain routes to a remote server (e.g. an existing API). Avoids CORS pain when consuming remote services.
- Configurable by command-line options, stored config or both
- Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
- Configurable log output, compatible with [Goaccess, Logstalgia and glTail](https://github.com/lwsjs/local-web-server/blob/master/doc/visualisation.md)
- Configurable CORS rules. All origins allowed by default.
**Backend scenarios covered:**
**Use cases**
* Existing API
* Mock API
* Websocket server
**Server options**
* HTTP or HTTPS server
* HTTPS is strictly required by some modern techs (ServiceWorker, Media Capture and Streams etc.)
* Configurable middleware stack
* Use any combination of built-in and custom middleware
* specify options (for command line or config)
* Accepts Koa v1 or 2 middleware
**Built-in Middleware stack**
* Rewrite routes to local or remote resources
* Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
* Configurable log output, compatible with [Goaccess, Logstalgia and glTail](https://github.com/lwsjs/local-web-server/blob/master/doc/visualisation.md)
* Proxy server
* Map local routes to remote servers. Removes CORS pain when consuming remote services.
* Back-end service mocking
* Prototype a web service, microservice, REST API etc.
* Mocks are defined with config (static), or code (dynamic).
* CORS-friendly, all origins allowed by default.
**Personalised stack**
Things you can build:
- Simple static website
- Single Page Application
- Works well with React, Angular or vanilla JS.
- Real or mock web services
- e.g. a RESTful API or microservice
- Mocks are defined with config (static), or code (dynamic).
- Websocket server
## Synopsis
local-web-server is a command-line tool. To serve the current directory, run `ws`.
<pre><code>$ ws --help
<strong>local-web-server</strong>
A simple web-server for productive front-end development.
A convenient local web server to support productive, full-stack Javascript