help icon indicating copy to clipboard operation
help copied to clipboard

Node and Authentication

Open rayj00 opened this issue 3 years ago • 7 comments

  • Node.js Version: v14.4.0
  • OS: Ubuntu 20.04 Server
  • Scope (install, code, runtime, meta, other?): Code
  • Module (and version) (if relevant):

I am trying to implement node authentication

// I am an example of JS code

Server.js code:

const fs = require('fs'); const path = require('path'); const url = require('url'); var httpServer = require('http'); const auth = require("http-auth"); const basic = auth.basic( { realm: "Private Area", file: __dirname + "/htpasswd", }); ... ... function serverHandler(request, response) {

console.log("dirname = ", __dirname); //console.log(user = ${basic.file} + ${user});

basic.check(request, response => {
        response.end(`Welcome to private area, ${basic.file} + ${username}`);

});


I know I'm missing something....but what?

Thanks,

Ray

rayj00 avatar Mar 12 '21 19:03 rayj00