<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".dwg" mimeType="application/acad" />
      <mimeMap fileExtension=".ipa" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".plist" mimeType="text/xml" />
    </staticContent>

    <security>
      <requestFiltering>
        <requestLimits maxUrl="40960" maxQueryString="20480" />
      </requestFiltering>
    </security>

    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
      </customHeaders>
    </httpProtocol>

    <rewrite>
      <rules>
        <rule name="wwwroot-static" stopProcessing="true">
          <match url="([\S]+[.](html|htm|svg|js|css|png|gif|jpg|jpeg|ico|eot|woff|woff2))" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_URI}" pattern="api/" negate="true" />
            <add input="{REQUEST_URI}" pattern="report/" negate="true" />
            <add input="{REQUEST_URI}" pattern="files/" negate="true" />
          </conditions>
          <action type="Rewrite" url="wwwroot/frontend/{R:1}" />
        </rule>

        <rule name="empty-root-index" stopProcessing="true">
          <match url="^$" />
          <action type="Rewrite" url="wwwroot/frontend/index.html" />
        </rule>

        <rule name="React Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="api/" negate="true" />
            <add input="{REQUEST_URI}" pattern="files/" negate="true" />
            <add input="{REQUEST_URI}" pattern="report/" negate="true" />
          </conditions>
          <action type="Rewrite" url="wwwroot/frontend/index.html" />
        </rule>

      </rules>
    </rewrite>

    <handlers>
      <add name="aspNetCore" path="api" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      <add name="aspNetCoreFiles" path="files" verb="GET" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      <add name="aspNetCoreReport" path="report" verb="GET" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\FMSAdmin.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
  </system.webServer>
</configuration>