简体   繁体   English

使用 node.js 运行 hmtl 页面时避免登录弹出窗口

[英]Avoid sign-in popup when running hmtl page with node.js

We're creating a web app in node.js.我们正在 node.js 中创建一个 Web 应用程序。 For this we're following this example to see how things are done.为此,我们将按照此示例查看事情是如何完成的。 Whenever we work with an express-session there is a credential pop-up displayed when accessing the page in the browser.每当我们使用express-session时,在浏览器中访问页面时都会显示一个凭据弹出窗口。

弹出窗口显示

  app.use(session({
    proxy: true,
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: false,
    rolling: true,
    name: 'sid', 
    cookie: {
      maxAge: 20 * 60 * 1000
    }
  }));

Searching the web I found this which talks about setting the proxy setting in the session .在网上搜索我发现这个讨论在session设置proxy设置。 However, after trying all options we still get the pop-up.但是,在尝试了所有选项后,我们仍然会看到弹出窗口。 Installing stuff through npm works fine without issue, even loading pages where no express-session are used.通过 npm 安装东西可以正常工作,甚至加载没有使用express-session页面。

How can we avoid this pop-up?我们怎样才能避免这个弹出窗口? Thank you for your help.感谢您的帮助。

I finally nailed this down.我终于确定了这一点。 It was something completely unrelated.那是完全不相关的东西。 As we are using bootstrap 4 we get the sign in pop up when we don't include the correct javascript files required by bootstrap at the end of the HTML page:当我们使用bootstrap 4时,当我们没有在 HTML 页面的末尾包含bootstrap所需的正确 javascript 文件时,我们会弹出sign in

<body>
    <!-- Other html code -->

    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="/js/jquery.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
</body>

Including this at the end of the page removed the annoying pop-up.在页面末尾包含这个删除了烦人的弹出窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM