节点API响应问题

时间:2019-10-25 15:50:20

标签: node.js api express

我已经在IIS中部署了节点api,并且https已绑定到443端口。

在代码中,我正在使用process.env.PORT || 446。

浏览时,我无法从https://localhost:443获得响应,而是从https://localhost:446获得

server.js

var https = require('https');
var fs    = require('fs');

var options = {
    pfx : fs.readFileSync('./secure.pfx'),
    passphrase : 'secure'
}

var app = require('./app')

var port = process.env.PORT || 446

var server = https.createServer(options,app)

server.listen(port)

webconfig.js

<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="server.js" verb="*" modules="iisnode" />
    </handlers>

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

        </system.webServer>
</configuration>

它不在绑定的端口上运行,但始终占用446。

0 个答案:

没有答案