By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Found` as a file does not exist with that path. By marking `index.html` as the SPA you create this rule:
By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Found` as a file does not exist with that path. By marking `index.html` as the SPA you create this rule:
*If a static file at the requested path exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then serve the SPA and handle the route client-side.*
*If a static file at the requested path exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then serve the specified SPA and handle the route client-side.*
### Access Control
### Access Control
By default, access to all files is allowed (including dot files). Use `--forbid` to establish a blacklist:
By default, access to all files is allowed (including dot files). Use `--forbid` to establish a blacklist:
```sh
```sh
$ ws --forbid .json .yml
$ ws --forbid '*.json''*.yml'
serving at http://localhost:8000
serving at http://localhost:8000
```
```
@ -51,48 +51,65 @@ serving at http://localhost:8000
### URL rewriting
### URL rewriting
Your application requested `/css/style.css` but it's stored at `/build/css/style.css`. Create a rewrite rule:
Your application requested `/css/style.css` but it's stored at `/build/css/style.css`. To avoid a 404 you need a rewrite rule:
If a deep structure is involved it may be easier to mount the entire contents of `/build/css` to the `/css` path: (matches any stylesheet path under `/css`, `/css/a`, `/css/a/b` etc.)
With a deep CSS directory structure it may be easier to mount the entire contents of `/build/css` to the `/css` path:
```sh
```sh
$ ws --rewrite "/css/* -> /build/css/$1"
$ ws --rewrite '/css/* -> /build/css/$1'
```
```
this rewrites `/css/a` as `/build/css/a`, `/css/a/b/c` as `/build/css/a/b/c` etc.
#### Proxied rewrite
If the `to` address contains a hostname local-web-server will act as a proxy - the remote resource will be fetched and returned
#### Proxied requests
If the `to` URL contains a remote host, local-web-server will act as a proxy - fetching and responding with the remote resource.
By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Found` as a file does not exist with that path. By marking `index.html` as the SPA you create this rule:
By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Found` as a file does not exist with that path. By marking `index.html` as the SPA you create this rule:
*If a static file at the requested path exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then serve the SPA and handle the route client-side.*
*If a static file at the requested path exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then serve the specified SPA and handle the route client-side.*
### Access Control
### Access Control
By default, access to all files is allowed (including dot files). Use `--forbid` to establish a blacklist:
By default, access to all files is allowed (including dot files). Use `--forbid` to establish a blacklist:
```sh
```sh
$ ws --forbid .json .yml
$ ws --forbid '*.json''*.yml'
serving at http://localhost:8000
serving at http://localhost:8000
```
```
@ -51,48 +51,65 @@ serving at http://localhost:8000
### URL rewriting
### URL rewriting
Your application requested `/css/style.css` but it's stored at `/build/css/style.css`. Create a rewrite rule:
Your application requested `/css/style.css` but it's stored at `/build/css/style.css`. To avoid a 404 you need a rewrite rule:
If a deep structure is involved it may be easier to mount the entire contents of `/build/css` to the `/css` path: (matches any stylesheet path under `/css`, `/css/a`, `/css/a/b` etc.)
With a deep CSS directory structure it may be easier to mount the entire contents of `/build/css` to the `/css` path:
```sh
```sh
$ ws --rewrite "/css/* -> /build/css/$1"
$ ws --rewrite '/css/* -> /build/css/$1'
```
```
this rewrites `/css/a` as `/build/css/a`, `/css/a/b/c` as `/build/css/a/b/c` etc.
#### Proxied rewrite
If the `to` address contains a hostname local-web-server will act as a proxy - the remote resource will be fetched and returned
#### Proxied requests
If the `to` URL contains a remote host, local-web-server will act as a proxy - fetching and responding with the remote resource.