How to find out why Angular app running on IIS does not allow 'Open link in new tab' for a route / url?

Viewed 214

This works on angular development server, but on IIS (10.0) I get

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

on Chrome. When I click the link it works without any problem. With angular development server I use proxy.conf.json to enable API-calls. In IIS these are defined as follows.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="ReverseProxyInboundRule3" stopProcessing="true">
                    <match url="(.*pn/api/.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="{C:1}://b-XXX:19100/{C:3}" logRewrittenUrl="true" />
                </rule>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*api/.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{CACHE_URL}" pattern="^(https?)://([^/]+).*(api/.*)" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://b-ZZZ:18221/{C:3}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
        <staticContent>
            <mimeMap fileExtension=".cmap" mimeType="text/plain" />
            <mimeMap fileExtension=".pdm" mimeType="text/plain" />
            <mimeMap fileExtension=".pdt" mimeType="text/plain" />
        </staticContent>
    </system.webServer>
</configuration>

My index.html looks like this:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>YYY App</title>
  <base href="/yyyapp/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.0a90b702423cc0234e73.css"></head>
<body>
  <app-root>Loading...</app-root>
<script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="polyfills.a73720f7fce1093697ef.js"></script><script type="text/javascript" src="scripts.9142a59cca85c6bb7aa5.js"></script><script type="text/javascript" src="main.fc2905abff461388a63e.js"></script></body>
</html>
1 Answers

Add web.config file in the server

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="AngularJS" 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>
Related