http://computertriksno1.blogspot.in/

Node Expressjs api host under angular build project in iis using web.config

26 Sep 2018 0 comments





<configuration>
  <system.webServer>
    <!-- indicates that the hello.js file is a node.js application
    to be handled by the iisnode module -->
  <staticContent>
    <remove fileExtension=".woff" />
 <remove fileExtension=".json" />
    <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
    <!-- 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/urlrewrite/myapp
        http://localhost/node/urlrewrite/myapp/foo
        http://localhost/node/urlrewrite/myapp/foo/bar/baz?param=bat
   
    -->

 <handlers>
            <add name="iisnode" path="api/backend/src/server.js" verb="*" modules="iisnode" />
        </handlers>
<rewrite>
      <rules>
     <rule name="HTTPS force" enabled="true" stopProcessing="true">
   <match url="(.*)" />
   <conditions>
   <add input="{HTTPS}" pattern="^OFF$" />
   </conditions>
   <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
  </rule>
  <rule name="API" stopProcessing="true">
          <match url="api/*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="api/backend/src/server.js" />
        </rule>
        <rule name="AngularJS Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Share this article :

Post a Comment

 
Support : GDDon | Creating Website | Gddon |
Copyright © 2013. Computer Tricks and Tips for System - All Rights Reserved
Template Created by Creating Website Modify by GDDon.Com
Proudly powered by Blogger