javascript - 为什么我的快速路由函数不会触发它们的回调函数?
问题描述
我已经通过护照身份验证建立了一些路由,但它们都没有触发他们的回调。路线正在运行,但没有任何内容记录到控制台供我调试。谁能帮我弄清楚为什么?下面是我的 server.js 的一部分
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(passport.initialize());
app.use(passport.session());
app.use(cors({
origin: 'https://localhost:3000',
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
allowedHeaders: "Content-Type,Authorization",
credentials: true
}));
app.get("/", (req, res) => {
console.log('Welcome')
});
app.get("/auth/yahoo", passport.authenticate("yahoo"), (req, res) => {
console.log('Authenticating..')
});
app.get("/auth/yahoo/redirect",
passport.authenticate("yahoo", {
failureRedirect: "/auth/login/failed"
}),
function(req, res) {
console.log('Redirecting..')
// Successful authentication, redirect home.
res.redirect('/profile');
}
);
app.get("/auth/login/failed", (req, res) => {
console.log('Authentication Failed')
});
const port = 9000;
const httpsOptions = {
key: fs.readFileSync('./security/key.pem'),
cert: fs.readFileSync('./security/cert.pem')
};
const server = https.createServer(httpsOptions, app)
.listen(port, () => {
console.log('server running at ' + port)
});
谢谢!
解决方案
推荐阅读
- cryptography - 使用 Palisade 库的同态加密
- unit-testing - 在没有实际数据库调用的情况下在具有 N 层的 Web api 中进行单元测试
- google-cloud-platform - 如何以编程方式将角色添加到云构建服务帐户?
- azure - 天蓝色管道 cron 未运行
- excel - 在 vba 中,“On Error GoTo”语句不起作用。编译器在语句后给出错误
- sql - 如何获取日期范围之间的所有日期(包括 start_date 和 end_date)
- c# - 是否有可能在源代码中抑制 sonarcloud 的警告?
- excel - 字符串中的通配符
- docker - 为什么dockerfile中的添加或复制命令不添加新文件
- jenkins - 在 Jenkins 管道中运行并行 kubernetes 作业