【发布时间】:2022-02-14 17:06:54
【问题描述】:
NodeJS 中是否有请求路径正则表达式匹配器,基本上我想构建一个允许某些路径跳过令牌验证的功能。 如何在 Express 中进行操作。
function verifyToken(req, res, next) {
// Get auth header value
const whitelistPaths = ["/ping","**/swagger-ui.html/**","/health/*"];
if(req.path matches any of values in whitelist array) , call next()
const bearerHeader = req.headers["Authorization"];
Authentication check
router.get("*", verifyToken, apiProxy);
【问题讨论】: