LoginSignup
0
0

More than 1 year has passed since last update.

Express.jsにPassport.jsで、任意のフォルダ配下のみをBasic認証する その2

Posted at

概要

expressを使って特定フォルダのみパスワードを掛けたい。

こんどこそ、express-basic-authを使って。

const express = require("express");
const basicAuth = require("express-basic-auth");
const PORT = 3000;
const app = express();
//
app.use("/admin", basicAuth({
    users: { 'user': 'pass' },
    challenge: true,
}), express.static("public/admin"));
//
app.use("/", express.static("public/") );
app.listen(PORT, () => {
  console.log("app listening on port " + PORT + " " + new Date());
});

結論

やったー。動いた!ばんざーい。
よっしあぁ。

参考サイト

git

https://github.com/kawamurashin/express-auth-test

Express.jsにPassport.jsで、任意のフォルダ配下のみをBasic認証する
https://qiita.com/hoshimado/items/272fba1aeb728e14f278

express-basic-auth  
https://github.com/LionC/express-basic-auth

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0