【问题标题】:if i do app.use(express.static(path.join(__dirname, 'public'))); it always opens index.html file in public .如果我做 app.use(express.static(path.join(__dirname, 'public')));它总是公开打开 index.html 文件。
【发布时间】:2017-06-03 17:37:50
【问题描述】:

当服务器开始使用 post 方法时,我无法公开打开 register.html 文件。 默认情况下,如果 index.html 文件丢失,则在服务器启动期间它会给出 CANNOT/GET。 所以帮我弄清楚..如何打开注册.html

【问题讨论】:

    标签: node.js express post node-modules


    【解决方案1】:

    express.static 中间件只接受 GET 请求。如果你想要 POST 方法中的文件,你需要单独定义一个路由。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 2016-08-22
      • 2016-03-14
      • 1970-01-01
      相关资源
      最近更新 更多