节点。在登录屏幕上绕过身份验证图像

时间:2016-04-09 06:00:32

标签: node.js

我在登录页面上使用背景图像,但在部署到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');
      }
    }
  });

1 个答案:

答案 0 :(得分:0)

您的错误是您已经硬编码-(id) initWithCoder:(NSCoder *)aDecoder { if((self = [super init])){ self.layer.cornerRadius = 4.0; self.clipsToBounds = true; self.backgroundColor = [UIColor colorWithRed:69/255 green:83/255 blue:153/255 alpha:1]; } return nil; } -(void) setHighlighted:(BOOL)highlighted { [super setHighlighted:highlighted]; if(highlighted){ self.backgroundColor = [UIColor colorWithRed:83/255 green:98/255 blue:178/255 alpha:1]; } else { self.backgroundColor = [UIColor colorWithRed:69/255 green:83/255 blue:153/255 alpha:1]; } } 标题,此处:

Access-Control-Allow-Origin

部署到heroku后,主持人不再res.header("Access-Control-Allow-Origin", "http://localhost"); 。我建议你将你的主机名存储在一个环境变量中,这个变量在生产或开发时会有所不同。您可以使用例如dotenv模块来简化此过程。