1
我在登錄頁面上使用背景圖像,但在部署到heroku時未獲取加載。它在Localhost上運行良好。當我打開調試器窗口並在瀏覽器中打開圖像URL時,它將重定向到登錄屏幕。如何避免在登錄屏幕上驗證背景圖像的身份驗證。節點。在登錄屏幕上繞過圖像驗證
模板代碼中的登錄是如下:
div(class="container" style="background-image:url(../images/school-wallpaper.jpg);height:650px;width:100%")
form(class="form-signin" method="post")
h2(class="form-signin-heading") Please sign in
label(for="inputEmail", class="sr-only")
Email address
input(type="email", id="inputEmail", name="email" class="form-control", placeholder="Email address", required, autofocus)
label(for="inputPassword", class="sr-only") Password
input(type="password", id="inputPassword", name= "password", class="form-control", placeholder="Password", required)
br
button(class="btn btn-lg btn-primary btn-block", type="submit") Sign in
#error
if error
label.error #{error}
和服務器端實現:
app.use(function(req, res, next) {
res.setHeader("Access-Control-Allow-Methods", "POST, PUT, OPTIONS, DELETE, GET");
res.header("Access-Control-Allow-Origin", "http://localhost");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
if(req.url.indexOf("/login")==0)
next()
else{
if(req.session.userProile){
next();
}
else{
res.redirect('/login');
}
}
});
感謝噸....它的工作原理。 –