gpt4 book ai didi

Does passport.js require additional config for Cyclic?(对于循环,passport.js是否需要额外的配置?)

转载 作者:bug小助手 更新时间:2023-10-24 22:40:58 26 4
gpt4 key购买 nike



Recently I changed the hosting of my node website for client from Glitch to Cyclic. But I found 2-3 days ago that after logging into the admin's dashboard, I was successfully redirected to the dashboard, but whenever I want to enter admin's pages I am redirected to the home page with the message "You do not have access to this page" (from middleware isLoggedIn). On localhost and Glitch, all work fine, but on Cyclic this problem. And here we come to the question from the question title: Does passport.js require additional config on Cyclic? I've already added a cookie parser.

最近,我将我的客户端节点网站的托管从故障更改为循环。但我在2-3天前发现,在登录到管理员的仪表板后,我成功地被重定向到仪表板,但每当我想进入管理员的页面时,我都会被重定向到主页,并显示消息“You‘t Have Access to This Page”(从中间件isLoggedIn)。在本地主机和小故障上,一切都工作得很好,但在循环上这个问题。现在我们来看问题标题中的问题:passport.js是否需要在循环上进行额外的配置?我已经添加了一个Cookie解析器。


My current app.js file:

我当前的app.js文件:


const express               = require("express"),
app = express(),
mongoose = require("mongoose"),
helmet = require("helmet"),
Driver = require("./models/driver"),
passport = require("passport"),
announcementRoutes = require("./routes/announcement"),
applicationRoutes = require("./routes/application"),
characteristicRoutes = require("./routes/characteristic"),
courseRoutes = require("./routes/course"),
installmentRoutes = require("./routes/installment"),
eventRoutes = require("./routes/event"),
driverRoutes = require("./routes/driver"),
linksRoutes = require("./routes/links"),
officesRoutes = require("./routes/office"),
subpageRoutes = require("./routes/subpage"),
messageRoutes = require("./routes/message"),
listRoutes = require("./routes/list"),
listElementRoutes = require("./routes/listElement"),
apiRoutes = require("./routes/api"),
galleryRoutes = require("./routes/gallery"),
indexRoutes = require("./routes/index"),
LocalStrategy = require("passport-local"),
methodOverride = require("method-override"),
bodyParser = require("body-parser"),
cookieParser = require('cookie-parser'),
flash = require("connect-flash");

mongoose.connect(process.env.DATABASE_URL, {useNewUrlParser: true});





app.use(flash());
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser())
app.use(express.static(__dirname + "/public"));
app.use(helmet({
contentSecurityPolicy: false
}))
app.use(methodOverride("_method"));

app.use(require("express-session")({
secret: "<key>",
resave: false,
saveUninitialized: false
}));
app.use(function(req, res, next) {
res.locals.host = req.headers.host;
res.locals.error = req.flash("error");
res.locals.success = req.flash("success");
res.locals.currentUser = req.user;
next();
});
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(Driver.authenticate()));
passport.serializeUser(Driver.serializeUser());
passport.deserializeUser(Driver.deserializeUser());



app.use("/gallery",galleryRoutes);
app.use("/courses/:course_id/installments",installmentRoutes);
app.use("/courses/:course_id/events",eventRoutes);
app.use("/courses",courseRoutes);
app.use("/courses/:course_id/characteristics",characteristicRoutes);
app.use("/applications",applicationRoutes);
app.use("/announcements",announcementRoutes);
app.use("/driver",driverRoutes);
app.use("/driver/:driver_id/offices",officesRoutes);
app.use("/links",linksRoutes);
app.use("/subpages",subpageRoutes);
app.use("/subpages/:subpage_id/messages",messageRoutes);
app.use("/subpages/:subpage_id/lists",listRoutes);
app.use("/subpages/:subpage_id/lists/:list_id/listElements",listElementRoutes);
app.use("/api", apiRoutes);
app.use(indexRoutes);


app.listen(process.env.PORT);

更多回答
优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com