如何在iis上正确安装Node.js Express应用程序?

时间:2019-07-16 11:16:05

标签: node.js express iis iisnode

我被要求构建一个简单的应用程序,该应用程序从数据库中获取一些数据并将其返回,因为我使用express作为后端工具,而将angular作为前端。 现在,我被要求将其部署在使用Windows IIS的实时服务器上,为此,我使用IISnode进行了安装,并且运行良好,但是当我访问应用程序时,出现此错误: “(node:7016)[DEP0005] DeprecationWarning:由于安全性和可用性问题,不推荐使用Buffer()”。

问题在于我没有在应用程序中的任何地方使用该功能。

这是我的app.js代码: `

var express = require('express');

var indexRouter = require('./routes/index');

var app = express();

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "http://localhost:4200");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

  next();
});

app.use(express.json());
app.use(express.urlencoded({ extended: false }));

app.use('/', indexRouter);



// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

module.exports = app;`

这是web.config文件:

<configuration>
  <system.webServer>

    <!-- indicates that the hello.js file is a node.js application 
    to be handled by the iisnode module -->

    <handlers>
      <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
    </handlers>

    <!-- use URL rewriting to redirect the entire branch of the URL namespace
    to hello.js node.js application; for example, the following URLs will 
    all be handled by hello.js:

        http://localhost/node/express/myapp/foo
        http://localhost/node/express/myapp/bar

    -->

    <rewrite>
      <rules>
        <rule name="myapp">
          <match url="/*" />
          <action type="Rewrite" url="app.js" />
        </rule>
      </rules>
    </rewrite>

  </system.webServer>
</configuration>

谁能告诉我我做错了吗?

0 个答案:

没有答案