iisnode and express

邮差的信 提交于 2019-12-04 10:09:44
rainabba

A good suggestion can be found at: Can an iisnode-hosted web application work out the virtual path at which it is hosted? Essentially, you use one small variable to abstract the path and an environment variable (if it exists) to control it. Another good post (possibly better solution) can be found at https://github.com/tjanczuk/iisnode/issues/160

The easiest way to address this problem is to create a dedicated IIS website for your application as opposed to creating an IIS application within an IIS website like you did.

If you have a dedicated website for your node.js application in IIS, the application is accessible at the root of the URL space, e.g. http://myapp.com/, which is what the default express route configuration expects. In contrast, if you create an IIS application within an IIS website to host your node.js application (say devices), it is accessible at a URL subordinate to the root URL of the web site, e.g. http://myapp.com/devices/. The extra URL path segment (devices) is something your express app does not expect and is not configured to process, and therefore it rejects the request.

If you insist on hosting the node.js application as an IIS application in IIS, you will need to augment your express route configuration to expect the extra URL path segment that matches the IIS application name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!