Calling localhost urls on Azure's IISNode

后端 未结 2 891
南方客
南方客 2021-01-21 19:25

I am running into some issues with running a Node app on Azure WebSites due to IISNode. Basically the issue is that I am relying on the port number being a number, which frankly

相关标签:
2条回答
  • 2021-01-21 19:51

    Windows Azure Websites uses IISNode to host the Node process inside of IIS. Your Node site is actually given a Named Pipe which receives the incoming requests, not a TCP port like you would use when running locally or hosting yourself. Even if you could open a TCP port, Azure Websites are really only meant for traditional websites and don't have a way to open ports to the outside world.

    As we will get this error message like: Error: connect EACCES 127.0.0.1:80 at Object.exports._errnoException (util.js:837:11) at exports._exceptionWithHostPort (util.js:860:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)

    As a workaround, If your URL which is wanted is in your expressjs project, you can leverage res.redirect or custom build-in function to handle params. Or you can migrate your project to Azure VM which offers greater flexibility for your need.

    0 讨论(0)
  • 2021-01-21 19:57

    I posted another question that was related to this problem, and I found a decent programmatic solution that applies to this problem.

    Turns out it is possible to call express.Router directly by using the (non-public/unofficial) Router#handle method with a stubbed out request and response object. For details on that approach you can refer to this answer.

    It turned out that the named pipe approach was non-viable, so calling the Router directly seems like the closest fit for the problem at hand.

    0 讨论(0)
提交回复
热议问题