How to password protect a server using Basic Authentication - lwsjs/local-web-server GitHub Wiki

HTTP Basic Authentication is provided by the lws-basic-auth module which is part of the built-in stack.

  1. Launch ws supplying --auth.user and --auth.pass values. For added security you could also add the --https option.

    $ ws --auth.user lloyd --auth.pass chimps
    
  2. Navigate to the server - you will now be prompted to input a username and password.

To persist options across sessions, add them to the config.

module.exports = {
  authUser: 'lloyd',
  authPass: 'chimps'
}