A lean, modular web server for rapid full-stack development.
--cors.private-network-access
flag.exports
, conditional exports and exports patterns have been retro-fitted back to v12 (see the Package module history)Users of Node.js v12.20 and above may now use local-web-server (previously, you needed a minimum of node v14). There are no further changes.
This is a refresher release - there are no functional or behavioural changes to the web server itself.
lws-
in plugin names, (i.e. you could use --stack static
instead of --stack lws-static
). This was ambigious and introduced the risk of incorrectly loading a module named static
, if it existed.Lws.create
method. You now need to await
the result.
const lws = await Lws.create()
lws.config.js
may now also be named lws.config.mjs
or lws.config.cjs
if preferred.--stack static
) please use the full name (e.g. --stack lws-static
)await
the result.import
to load the library.--rewrite
rules. This greatly speeds up the development of custom rewrites. Full documentation here.
An example, testing a rewrite to a remote server:
$ npx lws-rewrite '/npm/:pkg' 'https://npmjs.org/package/:pkg' '/npm/renamer'
https://npmjs.org/package/renamer
The same feature has also been added to lws-redirect.
--qr
option to display a QR Code for the chosen URL.
--list-network-interfaces
to display the available network interface names. Used in conjunction with the --qr
option.secure
attribute from remote, rewrite-target cookies is now the default behaviour. Set the --rewrite.keep-secure-attr
flag to disable this. https://github.com/lwsjs/local-web-server/issues/141
--websocket
option.
--server
option.
ws middleware-list
command is now ws --default-stack
.--rewrite
has been upgraded to use the latest version of path-to-regexp, which has changed the syntax for the wildcard asterix.--static.extensions
. #120, docs
--spa.asset-test-fs
https://github.com/lwsjs/spa/pull/1, docs
--rewrite
now works behind an HTTP proxy. #114configFile
is now honoured when using programmatic API. #115Some tips on upgrading from v2 to v3.
--rewrite
and have an asterix wildcard in your from
expression (e.g. /api/*
) you'll need to change the asterix to (.*)
, e.g. /api/(.*)
.LocalWebServer.create
rather than localWebServer.listen
as before.npm i --save-dev lws-mock-responses
ws --stack mock-responses static index
If you have any questions, post an issue - thanks.
Added --http2
option, which uses node's built-in HTTP2 support. See this wiki page for usage examples.
The built-in --https
certificate had expired. This release contains a new certificate valid for ten years. You may need to mark the new certificate as trusted.