I'm trying to add basic authentication to my app using the express-basic-auth. I'm following the instructions on this page, which also says "If a request is found to not be authorized, it will respond with HTTP 401" but my app simply replies with status code 200 when I do not pass any credentials
It seems I've incorrectly configured express-basic-auth. What have I done wrong?
const express = require('express')
const app = express()
const port = 3001
const basicAuth = require('express-basic-auth')
app.use(basicAuth({
users: { 'admin': 'supersecret' },
}))
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})