I'm trying to check if someone has entered an authorized username and password in my link for a specific path called '/protected' example:
admin:admin@localhost:8080/protected
If the person has inputted this then he will arrive to a page says "welcome authorized"
If the person hasn't inputted the link like this instead just: localhost:8080/protected He will receive a message "not authorized" along with error 401
This is the code that i came up with but only if you are authorized will receive a message, else you don't receive anything.
router.get('/protected', basicAuth({
users: {'admin':'admin'}
}),(req,res)=>{
res.send('Welcome, authenticated client');
});