Can an iisnode-hosted web application work out the virtual path at which it is hosted?

后端 未结 4 1907
后悔当初
后悔当初 2021-01-12 18:46

I am using iisnode to host a node web application in IIS on Windows. When I set up my routes on the web server (say Express or Restify) I want do do it in a way that is inde

4条回答
  •  深忆病人
    2021-01-12 19:18

    Both express and restify allow the definition of paths with regex. By using regex paths you can avoid prefix issues entirely.

    Instead of

    server.get({ path: '/virtual/directory/structure/status/',...
    

    use

    server.get({ path: /.*\/status/,...
    

    and there'll be no need for any magic.

提交回复
热议问题